Part Number Hot Search : 
STA3350 T421004 0N08S 5KP20 LC46A 29312 B0505 BF494
Product Description
Full Text Search
 

To Download MC68HC812A4 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  mc68hc 8 12 a 4 /d rev 5 mc68hc 8 12 a 4 advance information hcmos microcontroller unit m 6 8h c 12m 6 1 2 m 6 8 h c 1 2 m 8 hc12m68h c
blank
MC68HC812A4 ? rev. 5.0  advance information motorola 3 MC68HC812A4 advance information motorola reserves the right to make changes without further notice to any products herein. motorola makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does motorola assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. "typical" parameters which may be provided in motorola data sheets and/or specifications can and do vary in different applications and actual performance may vary over time. all operating parameters, including "typicals" must be validated for each customer application by customer?s technical experts. motorola does not convey any license under its patent rights nor the rights of others. motorola products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the motorola product could create a situation where personal injury or death may occur. should buyer purchase or use motorola products for any such unintended or unauthorized application, buyer shall indemnify and hold motorola and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that motorola was negligent regarding the design or manufacture of the part. motorola, inc. is an equal opportunity/affirmative action employer. motorola and are registered trademarks of motorola, inc. digitaldna is a trademark of motorola, inc. ? motorola, inc., 2001
advance information MC68HC812A4 ? rev. 5.0 4 motorola advance information to provide the most up-to-date information, the revision of our documents on the world wide web will be the most current. your printed copy may be an earlier revision. to verify you have the latest information available, refer to: http://www.motorola.com/mcu/ the following revision history table summarizes changes contained in this document. for your convenience, the page number designators have been linked to the appropriate location. revision history date revision level description page number(s) august, 2001 4.0 figure 1-3. expanded wide mode sram expansion schematic (sheet 1 of 3) ? figure title changed from flash eeprom to sram and address line designators corrected 40 figure 1-4. expanded narrow mode sram expansion schematic (sheet 1 of 3) ? figure title changed from flash eeprom to sram and address line designators corrected 42 figure 8-16. chip-select control register 0 (csctl0) ? corrected reset value for cspoe (bit 5) 138 figure 10-1. clock module block diagram ? corrected e- and p-clock generator options 156 figure 11-1. pll block diagram ? revised diagram to show correct placement of divide-by-two block 170 12.11.2 timer port data direction register ? descriptive paragraph added for clarity 209 12.11.3 data direction register for timer port ? repetitive information removed. see 12.11.2 timer port data direction register 209 18.12 control timing ? minimum values added for pw irq and pw tim 329 18.14 non-multiplexed expansion bus timing ? table heading changed to reflect minimum and maximum values at 8 mhz 334 september, 2001 3 table 12-3. prescaler selection ? added value column and updated prescale factors 197 18.11 eeprom characteristics ? corrected minimum and maximum values for programming and erase times 328
advance information MC68HC812A4 ? rev. 5.0 motorola list of sections 5 advance information ? MC68HC812A4 list of sections section 1. general description . . . . . . . . . . . . . . . . . . . . 31 section 2. register block . . . . . . . . . . . . . . . . . . . . . . . . 45 section 3. central processor unit (cpu12) . . . . . . . . . . 61 section 4. resets and interrupts . . . . . . . . . . . . . . . . . . 71 section 5. operating modes and resource mapping . . . . . . . . . . . . . . . 81 section 6. bus control and input/output (i/o) . . . . . . . 95 section 7. eeprom . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 section 8. memory expansion and chip-select . . . . . 123 section 9. key wakeups . . . . . . . . . . . . . . . . . . . . . . . . 145 section 10. clock module . . . . . . . . . . . . . . . . . . . . . . . 155 section 11. phase-lock loop (pll) . . . . . . . . . . . . . . . 169 section 12. standard timer module . . . . . . . . . . . . . . . 177 section 13. multiple serial interface (msi) . . . . . . . . . . 213 section 14. serial communications interface module (sci) . . . . . . . . . . . . . . . . . . . . . . . 223 section 15. serial peripheral interface (spi) . . . . . . . . 263 section 16. analog-to-digital converter (atd) . . . . . . 285 section 17. development support . . . . . . . . . . . . . . . . 305 section 18. electrical characteristics . . . . . . . . . . . . . 321 section 19. mechanical specifications . . . . . . . . . . . . 339
MC68HC812A4 ? rev. 5.0 advance information 6 list of sections motorola list of sections
advance information MC68HC812A4 ? rev. 5.0 motorola table of contents 7 advance information ? MC68HC812A4 table of contents section 1. general description 1.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31 1.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31 1.3 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32 1.4 ordering information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33 1.5 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 1.6 signal descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35 section 2. register block 2.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45 2.2 overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 2.3 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46 2.4 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60 section 3. central processor unit (cpu12) 3.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61 3.2 overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 3.3 programming model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62 3.4 cpu registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 3.4.1 accumulators a and b . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63 3.4.2 accumulator d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63 3.4.3 index registers x and y. . . . . . . . . . . . . . . . . . . . . . . . . . . .64
MC68HC812A4 ? rev. 5.0 advance information 8 table of contents motorola table of contents 3.4.4 stack pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 3.4.5 program counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65 3.4.6 condition code register . . . . . . . . . . . . . . . . . . . . . . . . . . .65 3.5 data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .66 3.6 addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67 3.7 indexed addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . .68 3.8 opcodes and operands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69 section 4. resets and interrupts 4.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71 4.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72 4.3 exception priority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 4.4 maskable interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .73 4.5 interrupt registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75 4.5.1 interrupt control register . . . . . . . . . . . . . . . . . . . . . . . . .75 4.5.2 highest priority i interrupt register . . . . . . . . . . . . . . . . . .76 4.6 resets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 4.6.1 power-on reset. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .76 4.6.2 external reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .77 4.6.3 cop reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .77 4.6.4 clock monitor reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 4.7 effects of reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 4.7.1 operating mode and memory map. . . . . . . . . . . . . . . . . . . .78 4.7.2 clock and watchdog control logic . . . . . . . . . . . . . . . . . . .78 4.7.3 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .78 4.7.4 parallel i/o . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .78 4.7.5 central processor unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79 4.7.6 memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79 4.7.7 other resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79 4.8 interrupt recognition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79
table of contents advance information MC68HC812A4 ? rev. 5.0 motorola table of contents 9 section 5. operating modes and resource mapping 5.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81 5.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81 5.3 operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82 5.3.1 normal operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . .83 5.3.1.1 normal expanded wide mode . . . . . . . . . . . . . . . . . . . . .83 5.3.1.2 normal expanded narrow mode . . . . . . . . . . . . . . . . . . .83 5.3.1.3 normal single-chip mode . . . . . . . . . . . . . . . . . . . . . . . .83 5.3.2 special operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . .84 5.3.2.1 special expanded wide mode . . . . . . . . . . . . . . . . . . . . .84 5.3.2.2 special expanded narrow mode . . . . . . . . . . . . . . . . . . .84 5.3.2.3 special single-chip mode . . . . . . . . . . . . . . . . . . . . . . . .84 5.3.2.4 special peripheral mode . . . . . . . . . . . . . . . . . . . . . . . . .84 5.3.3 background debug mode. . . . . . . . . . . . . . . . . . . . . . . . . . .85 5.4 internal resource mapping. . . . . . . . . . . . . . . . . . . . . . . . . . . .85 5.5 mode and resource mapping registers . . . . . . . . . . . . . . . . .87 5.5.1 mode register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .87 5.5.2 register initialization register . . . . . . . . . . . . . . . . . . . . . . .89 5.5.3 ram initialization register . . . . . . . . . . . . . . . . . . . . . . . . . . 90 5.5.4 eeprom initialization register . . . . . . . . . . . . . . . . . . . . . . 90 5.5.5 miscellaneous mapping control register . . . . . . . . . . . . . . .91 5.6 memory map. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93 section 6. bus control and input/output (i/o) 6.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95 6.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95 6.3 detecting access type from external signals . . . . . . . . . . . . .96 6.4 registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .97 6.4.1 port a data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 6.4.2 port a data direction register . . . . . . . . . . . . . . . . . . . . . . . 98 6.4.3 port b data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 6.4.4 port b data direction register . . . . . . . . . . . . . . . . . . . . . . . 99 6.4.5 port c data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100 6.4.6 port c data direction register . . . . . . . . . . . . . . . . . . . . . .101
MC68HC812A4 ? rev. 5.0 advance information 10 table of contents motorola table of contents 6.4.7 port d data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102 6.4.8 port d data direction register . . . . . . . . . . . . . . . . . . . . . .103 6.4.9 port e data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . .104 6.4.10 port e data direction register . . . . . . . . . . . . . . . . . . . . . .105 6.4.11 port e assignment register . . . . . . . . . . . . . . . . . . . . . . . .106 6.4.12 pullup control register . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 6.4.13 reduced drive register . . . . . . . . . . . . . . . . . . . . . . . . . . .110 section 7. eeprom 7.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113 7.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113 7.3 eeprom programmer ? s model . . . . . . . . . . . . . . . . . . . . . . .114 7.4 eeprom control registers . . . . . . . . . . . . . . . . . . . . . . . . . . 116 7.4.1 eeprom module configuration register . . . . . . . . . . . . .116 7.4.2 eeprom block protect register . . . . . . . . . . . . . . . . . . . . 117 7.4.3 eeprom test register . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 7.4.4 eeprom programming register . . . . . . . . . . . . . . . . . . . .119 section 8. memory expansion and chip-select 8.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .123 8.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124 8.3 generation of chip-selects. . . . . . . . . . . . . . . . . . . . . . . . . . .126 8.3.1 chip-selects independent of memory expansion . . . . . . .126 8.3.2 chip-selects used in conjunction with memory expansion . . . . . . . . . . . . . . . . . . . . . . . .128 8.4 chip-select stretch. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130 8.5 memory expansion registers. . . . . . . . . . . . . . . . . . . . . . . . .132 8.5.1 port f data register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .132 8.5.2 port g data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . .132 8.5.3 port f data direction register . . . . . . . . . . . . . . . . . . . . . .133 8.5.4 port g data direction register. . . . . . . . . . . . . . . . . . . . . . 133 8.5.5 data page register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134 8.5.6 program page register . . . . . . . . . . . . . . . . . . . . . . . . . . .134
table of contents advance information MC68HC812A4 ? rev. 5.0 motorola table of contents 11 8.5.7 extra page register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .135 8.5.8 window definition register . . . . . . . . . . . . . . . . . . . . . . . . 135 8.5.9 memory expansion assignment register . . . . . . . . . . . . .136 8.6 chip-selects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137 8.7 chip-select registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 8.7.1 chip-select control register 0. . . . . . . . . . . . . . . . . . . . . .138 8.7.2 chip-select control register 1. . . . . . . . . . . . . . . . . . . . . .140 8.7.3 chip-select stretch registers . . . . . . . . . . . . . . . . . . . . . .141 8.8 priority. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .142 section 9. key wakeups 9.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .145 9.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .145 9.3 key wakeup registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .146 9.3.1 port d data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . .146 9.3.2 port d data direction register . . . . . . . . . . . . . . . . . . . . . .147 9.3.3 port d key wakeup interrupt enable register . . . . . . . . . .147 9.3.4 port d key wakeup flag register . . . . . . . . . . . . . . . . . . .148 9.3.5 port h data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . .148 9.3.6 port h data direction register . . . . . . . . . . . . . . . . . . . . . .149 9.3.7 port h key wakeup interrupt enable register . . . . . . . . . .149 9.3.8 port h key wakeup flag register . . . . . . . . . . . . . . . . . . .150 9.3.9 port j data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .150 9.3.10 port j data direction register . . . . . . . . . . . . . . . . . . . . . .151 9.3.11 port j key wakeup interrupt enable register . . . . . . . . . .151 9.3.12 port j key wakeup flag register . . . . . . . . . . . . . . . . . . .152 9.3.13 port j key wakeup polarity register . . . . . . . . . . . . . . . . .152 9.3.14 port j pullup/pulldown select register . . . . . . . . . . . . . . .153 9.3.15 port j pullup/pulldown enable register. . . . . . . . . . . . . . .154
MC68HC812A4 ? rev. 5.0 advance information 12 table of contents motorola table of contents section 10. clock module 10.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .155 10.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .156 10.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .156 10.3.1 clock generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .157 10.4 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .158 10.5 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .158 10.5.1 computer operating properly (cop) . . . . . . . . . . . . . . . . .158 10.5.2 real-time interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .159 10.5.3 clock monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 10.5.4 peripheral clock divider chains. . . . . . . . . . . . . . . . . . . . . 160 10.6 registers and reset initialization . . . . . . . . . . . . . . . . . . . . . . 163 10.6.1 real-time interrupt control register . . . . . . . . . . . . . . . . .163 10.6.2 real-time interrupt flag register . . . . . . . . . . . . . . . . . . .165 10.6.3 cop control register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 10.6.4 arm/reset cop timer register . . . . . . . . . . . . . . . . . . . . .168 section 11. phase-lock loop (pll) 11.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169 11.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169 11.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .170 11.4 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .172 11.5 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .172 11.6 registers and reset initialization . . . . . . . . . . . . . . . . . . . . . . 173 11.6.1 loop divider registers . . . . . . . . . . . . . . . . . . . . . . . . . . . .173 11.6.2 reference divider registers . . . . . . . . . . . . . . . . . . . . . . .174 11.6.3 clock control register . . . . . . . . . . . . . . . . . . . . . . . . . . . .175
table of contents advance information MC68HC812A4 ? rev. 5.0 motorola table of contents 13 section 12. standard timer module 12.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .177 12.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .178 12.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .179 12.4 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .180 12.5 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .184 12.5.1 prescaler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .184 12.5.2 input capture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .184 12.5.3 output compare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .185 12.5.4 pulse accumulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .186 12.5.4.1 event counter mode . . . . . . . . . . . . . . . . . . . . . . . . . . .187 12.5.4.2 gated time accumulation mode . . . . . . . . . . . . . . . . . .187 12.6 registers and reset initialization . . . . . . . . . . . . . . . . . . . . . . 188 12.6.1 timer ic/oc select register . . . . . . . . . . . . . . . . . . . . . . .188 12.6.2 timer compare force register . . . . . . . . . . . . . . . . . . . . .189 12.6.3 timer output compare 7 mask register . . . . . . . . . . . . . .189 12.6.4 timer output compare 7 data register. . . . . . . . . . . . . . .190 12.6.5 timer counter registers . . . . . . . . . . . . . . . . . . . . . . . . . .191 12.6.6 timer system control register . . . . . . . . . . . . . . . . . . . . .192 12.6.7 timer control registers 1 and 2 . . . . . . . . . . . . . . . . . . . .194 12.6.8 timer control registers 3 and 4 . . . . . . . . . . . . . . . . . . . .195 12.6.9 timer mask register 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . .196 12.6.10 timer mask register 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . .196 12.6.11 timer flag register 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .198 12.6.12 timer flag register 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .198 12.6.13 timer channel registers . . . . . . . . . . . . . . . . . . . . . . . . . .199 12.6.14 pulse accumulator control register . . . . . . . . . . . . . . . . . 200 12.6.15 pulse accumulator flag register . . . . . . . . . . . . . . . . . . . .202 12.6.16 pulse accumulator counter registers . . . . . . . . . . . . . . . .203 12.6.17 timer test register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .204 12.7 external pins. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .205 12.7.1 input capture/output compare pins . . . . . . . . . . . . . . . . .205 12.7.2 pulse accumulator pin . . . . . . . . . . . . . . . . . . . . . . . . . . . .205 12.8 background debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . .206
MC68HC812A4 ? rev. 5.0 advance information 14 table of contents motorola table of contents 12.9 low-power options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .206 12.9.1 run mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .206 12.9.2 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .206 12.9.3 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .207 12.10 interrupt sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .207 12.11 general-purpose i/o ports . . . . . . . . . . . . . . . . . . . . . . . . . . .207 12.11.1 timer port data register . . . . . . . . . . . . . . . . . . . . . . . . . .208 12.11.2 timer port data direction register . . . . . . . . . . . . . . . . . .209 12.12 using the output compare function to generate a square wave . . . . . . . . . . . . . . . . . . . . . . .210 12.12.1 sample calculation to obtain period counts . . . . . . . . . . .210 12.12.2 equipment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211 12.12.3 code listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211 section 13. multiple serial interface (msi) 13.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .213 13.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .213 13.3 sci features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .214 13.4 spi features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .215 13.5 msi block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .215 13.6 msi register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .216 13.7 general-purpose i/o ports . . . . . . . . . . . . . . . . . . . . . . . . . . .218 13.7.1 port s data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . .219 13.7.2 port s data direction register . . . . . . . . . . . . . . . . . . . . . .220 13.7.3 port s pullup and reduced drive control . . . . . . . . . . . . .221 13.7.4 port s wired-or mode control . . . . . . . . . . . . . . . . . . . . .222
table of contents advance information MC68HC812A4 ? rev. 5.0 motorola table of contents 15 section 14. serial communications interface module (sci) 14.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .223 14.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .224 14.3 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .224 14.4 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .226 14.5 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .227 14.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .229 14.6.1 data format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .229 14.6.2 baud rate generation . . . . . . . . . . . . . . . . . . . . . . . . . . . .230 14.6.3 transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .232 14.6.3.1 character length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .233 14.6.3.2 character transmission . . . . . . . . . . . . . . . . . . . . . . . . .233 14.6.3.3 break characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .234 14.6.3.4 idle characters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .235 14.6.4 receiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .236 14.6.4.1 character length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .237 14.6.4.2 character reception . . . . . . . . . . . . . . . . . . . . . . . . . . .237 14.6.4.3 data sampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .237 14.6.4.4 framing errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .243 14.6.4.5 baud rate tolerance . . . . . . . . . . . . . . . . . . . . . . . . . . .243 14.6.4.6 receiver wakeup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .245 14.6.5 single-wire operation . . . . . . . . . . . . . . . . . . . . . . . . . . . .247 14.6.6 loop operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .248 14.7 register descriptions and reset initialization . . . . . . . . . . . . 248 14.7.1 sci baud rate registers . . . . . . . . . . . . . . . . . . . . . . . . . .249 14.7.2 sci control register 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . .250 14.7.3 sci control register 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . .252 14.7.4 sci status register 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . .254 14.7.5 sci status register 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . .256 14.7.6 sci data registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .257 14.8 external pin descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . .258 14.8.1 txd pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 14.8.2 rxd pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 14.9 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .259
MC68HC812A4 ? rev. 5.0 advance information 16 table of contents motorola table of contents 14.10 low-power options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .259 14.10.1 run mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .259 14.10.2 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .259 14.10.3 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .259 14.11 interrupt sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .260 14.12 general-purpose i/o ports . . . . . . . . . . . . . . . . . . . . . . . . . . .260 14.13 serial character transmission using the sci . . . . . . . . . . . .260 14.13.1 equipment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .260 14.13.2 code listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .261 section 15. serial peripheral interface (spi) 15.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .263 15.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .264 15.3 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .264 15.4 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .265 15.5 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .266 15.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .266 15.6.1 master mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .267 15.6.2 slave mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .268 15.6.3 baud rate generation . . . . . . . . . . . . . . . . . . . . . . . . . . . .268 15.6.4 clock phase and polarity . . . . . . . . . . . . . . . . . . . . . . . . . .268 15.6.5 ss output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .271 15.6.6 single-wire operation . . . . . . . . . . . . . . . . . . . . . . . . . . . .272 15.7 spi register descriptions and reset initialization . . . . . . . . .273 15.7.1 spi control register 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 15.7.2 spi control register 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 15.7.3 spi baud rate register . . . . . . . . . . . . . . . . . . . . . . . . . . .276 15.7.4 spi status register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .277 15.7.5 spi data register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .278
table of contents advance information MC68HC812A4 ? rev. 5.0 motorola table of contents 17 15.8 external pins. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .279 15.8.1 miso (master in, slave out) . . . . . . . . . . . . . . . . . . . . . . .279 15.8.2 mosi (master out, slave in) . . . . . . . . . . . . . . . . . . . . . . .279 15.8.3 sck (serial clock) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .279 15.8.4 ss (slave select) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .280 15.9 low-power options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .280 15.9.1 run mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .280 15.9.2 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .280 15.9.3 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .281 15.10 interrupt sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .281 15.11 general-purpose i/o ports . . . . . . . . . . . . . . . . . . . . . . . . . . .281 15.12 synchronous character transmission using the spi. . . . . . .282 15.12.1 equipment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .282 15.12.2 code listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .282 section 16. analog-to-digital converter (atd) 16.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .285 16.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .286 16.3 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .286 16.4 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .287 16.5 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .288 16.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .290 16.7 registers and reset initialization . . . . . . . . . . . . . . . . . . . . . . 291 16.7.1 atd control register 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 16.7.2 atd control register 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 16.7.3 atd control register 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 16.7.4 adt control register 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 16.7.5 atd control register 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . 294 16.7.6 atd control register 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 16.7.7 atd status registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . .298 16.7.8 atd test registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .299 16.7.9 atd result registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
MC68HC812A4 ? rev. 5.0 advance information 18 table of contents motorola table of contents 16.8 low-power options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .301 16.8.1 run mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .301 16.8.2 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .301 16.8.3 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .301 16.9 interrupt sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .302 16.10 general-purpose ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .302 16.11 port ad data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .302 16.12 using the atd to measure a potentiometer signal . . . . . . . .303 16.12.1 equipment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .303 16.12.2 code listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .303 section 17. development support 17.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .305 17.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .305 17.3 instruction queue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .306 17.4 background debug mode (bdm) . . . . . . . . . . . . . . . . . . . . . .307 17.4.1 bdm serial interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . .308 17.4.2 enabling bdm firmware commands . . . . . . . . . . . . . . . . .311 17.4.3 bdm commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .311 17.5 bdm registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .314 17.5.1 bdm instruction register . . . . . . . . . . . . . . . . . . . . . . . . . .314 17.5.1.1 hardware command . . . . . . . . . . . . . . . . . . . . . . . . . . .314 17.5.1.2 firmware command. . . . . . . . . . . . . . . . . . . . . . . . . . . .315 17.5.2 bdm status register . . . . . . . . . . . . . . . . . . . . . . . . . . . . .317 17.5.3 bdm shift register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .318 17.5.4 bdm address register . . . . . . . . . . . . . . . . . . . . . . . . . . . .318 17.5.5 bdm ccr holding register . . . . . . . . . . . . . . . . . . . . . . . . 319 17.6 instruction tagging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .319
table of contents advance information MC68HC812A4 ? rev. 5.0 motorola table of contents 19 section 18. electrical characteristics 18.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .321 18.2 maximum ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .322 18.3 functional operating range. . . . . . . . . . . . . . . . . . . . . . . . . .323 18.4 thermal characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . .323 18.5 dc electrical characteristics . . . . . . . . . . . . . . . . . . . . . . . . . 324 18.6 supply current . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .325 18.7 atd maximum ratings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 18.8 atd dc electrical characteristcs. . . . . . . . . . . . . . . . . . . . . . 326 18.9 analog converter operating characteristics . . . . . . . . . . . . .327 18.10 atd ac operating characteristics . . . . . . . . . . . . . . . . . . . . .328 18.11 eeprom characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . .328 18.12 control timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .329 18.13 peripheral port timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .333 18.14 non-multiplexed expansion bus timing . . . . . . . . . . . . . . . . .334 18.15 spi timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .336 section 19. mechanical specifications 19.1 contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .339 19.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .339 19.3 112-pin low-profile quad flat pack (case 987) . . . . . . . . . .340
MC68HC812A4 ? rev. 5.0 advance information 20 table of contents motorola table of contents
advance information MC68HC812A4 ? rev. 5.0 motorola list of figures 21 advance information ? MC68HC812A4 list of figures figure title page 1-1 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 1-2 pin assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35 1-3 expanded wide mode sram expansion schematic . . . . . . . .40 1-4 expanded narrow mode sram expansion schematic . . . . . .42 2-1 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46 3-1 programming model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62 3-2 accumulator a (a). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63 3-3 accumulator b (b). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63 3-4 accumulator d (d) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63 3-5 index register x (x) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .64 3-6 index register y (y) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .64 3-7 stack pointer (sp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .64 3-8 program counter (pc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65 3-9 condition code register (ccr) . . . . . . . . . . . . . . . . . . . . . . . .65 4-1 interrupt control register (intcr) . . . . . . . . . . . . . . . . . . . . . . 75 4-2 highest priority i interrupt register (hprio) . . . . . . . . . . . . . .76 5-1 mode register (mode) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .87 5-2 register initialization register (initrg). . . . . . . . . . . . . . . . . .89 5-3 ram initialization register (initrm) . . . . . . . . . . . . . . . . . . . . 90 5-4 eeprom initialization register (initee) . . . . . . . . . . . . . . . . . 91 5-5 miscellaneous mapping control register (misc). . . . . . . . . . .92 5-6 memory map. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93
MC68HC812A4 ? rev. 5.0 advance information 22 list of figures motorola list of figures figure title page 6-1 port a data register (porta) . . . . . . . . . . . . . . . . . . . . . . . . .98 6-2 port a data direction register (ddra) . . . . . . . . . . . . . . . . . . 98 6-3 port b data register (portb) . . . . . . . . . . . . . . . . . . . . . . . . .99 6-4 port b data direction register (ddrb) . . . . . . . . . . . . . . . . . . 99 6-5 port c data register (portc). . . . . . . . . . . . . . . . . . . . . . . .100 6-6 port c data direction register (ddrc) . . . . . . . . . . . . . . . . .101 6-7 port d data register (portd). . . . . . . . . . . . . . . . . . . . . . . .102 6-8 port d data direction register (ddrd) . . . . . . . . . . . . . . . . .103 6-9 port e data register (porte) . . . . . . . . . . . . . . . . . . . . . . . .104 6-10 port e data direction register (ddre) . . . . . . . . . . . . . . . . . 105 6-11 port e assignment register (pear) . . . . . . . . . . . . . . . . . . .106 6-12 pullup control register (pucr) . . . . . . . . . . . . . . . . . . . . . . .109 6-13 reduced drive register (rdriv) . . . . . . . . . . . . . . . . . . . . . . 110 7-1 eeprom block protect mapping . . . . . . . . . . . . . . . . . . . . . .115 7-2 eeprom module configuration register (eemcr) . . . . . . .116 7-3 eeprom block protect register (eeprot) . . . . . . . . . . . . . 117 7-4 eeprom test register (eeprot) . . . . . . . . . . . . . . . . . . . .118 7-5 eeprom programming register (eeprog) . . . . . . . . . . . .119 8-1 chip-selects cs3 ? cs0 partial memory map . . . . . . . . . . . . .127 8-2 memory expansion and chip-select example . . . . . . . . . . . .129 8-3 chip-select with no stretch . . . . . . . . . . . . . . . . . . . . . . . . . . 130 8-4 chip-select with 1-cycle stretch . . . . . . . . . . . . . . . . . . . . . . 130 8-5 chip-select with 2-cycle stretch . . . . . . . . . . . . . . . . . . . . . . 131 8-6 chip-select with 3-cycle stretch . . . . . . . . . . . . . . . . . . . . . . 131 8-7 port f data register (portf) . . . . . . . . . . . . . . . . . . . . . . . .132 8-8 port g data register (portg) . . . . . . . . . . . . . . . . . . . . . . .132 8-9 port f data direction register (ddrf) . . . . . . . . . . . . . . . . . 133 8-10 port g data direction register (ddrg) . . . . . . . . . . . . . . . . . 133 8-11 data page register (dpage) . . . . . . . . . . . . . . . . . . . . . . . .134 8-12 program page register (ppage) . . . . . . . . . . . . . . . . . . . . .134 8-13 extra page register (epage) . . . . . . . . . . . . . . . . . . . . . . . .135 8-14 window definition register (windef) . . . . . . . . . . . . . . . . . . 135 8-15 memory expansion assignment register (mxar) . . . . . . . . .136
list of figures advance information MC68HC812A4 ? rev. 5.0 motorola list of figures 23 figure title page 8-16 chip-select control register 0 (csctl0) . . . . . . . . . . . . . . .138 8-17 chip-select control register 1 (csctl1) . . . . . . . . . . . . . . .140 8-18 chip-select stretch register 0 (csstr0) . . . . . . . . . . . . . . .141 8-19 chip-select stretch register 1 (csstr1) . . . . . . . . . . . . . . .141 9-1 port d data register (portd). . . . . . . . . . . . . . . . . . . . . . . .146 9-2 port d data direction register (ddrd) . . . . . . . . . . . . . . . . .147 9-3 port d key wakeup interrupt enable register (kwied) . . . .147 9-4 port d key wakeup flag register (kwifd). . . . . . . . . . . . . .148 9-5 port h data register (porth). . . . . . . . . . . . . . . . . . . . . . . .148 9-6 port h data direction register (ddrh) . . . . . . . . . . . . . . . . .149 9-7 port h key wakeup interrupt enable register (kwieh) . . . .149 9-8 port h key wakeup flag register (kwifh). . . . . . . . . . . . . .150 9-9 port j data register (portj) . . . . . . . . . . . . . . . . . . . . . . . .150 9-10 port j data direction register (ddrj) . . . . . . . . . . . . . . . . . . 151 9-11 port j key wakeup interrupt enable register (kwiej) . . . . .151 9-12 port j key wakeup flag register (kwifj) . . . . . . . . . . . . . .152 9-13 port j key wakeup polarity register (kpolj). . . . . . . . . . . .152 9-14 port j pullup/pulldown select register (pupsj) . . . . . . . . . .153 9-15 port j pullup/pulldown enable register (pulej). . . . . . . . . .154 10-1 clock module block diagram . . . . . . . . . . . . . . . . . . . . . . . . .156 10-2 internal clock relationships . . . . . . . . . . . . . . . . . . . . . . . . . .157 10-3 clock function register map . . . . . . . . . . . . . . . . . . . . . . . . .158 10-4 clock chain for sci0, sci1, rti, and cop . . . . . . . . . . . . . .160 10-5 clock chain for tim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161 10-6 clock chain for spi, atd and bdm . . . . . . . . . . . . . . . . . . . .162 10-7 real-time interrupt control register (rtictl) . . . . . . . . . . .163 10-8 real-time interrupt flag register (rtiflg) . . . . . . . . . . . . .165 10-9 cop control register (copctl) . . . . . . . . . . . . . . . . . . . . . . 165 10-10 arm/reset cop timer register (coprst) . . . . . . . . . . . . . .168 11-1 pll block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .170 11-2 pll register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .172
MC68HC812A4 ? rev. 5.0 advance information 24 list of figures motorola list of figures figure title page 11-3 loop divider register high (ldvh) . . . . . . . . . . . . . . . . . . . . 173 11-4 loop divider register low (ldvl) . . . . . . . . . . . . . . . . . . . . .173 11-5 reference divider register high (rdvh). . . . . . . . . . . . . . . . 174 11-6 reference divider register low (rdvl) . . . . . . . . . . . . . . . .174 11-7 clock control register (clkctl). . . . . . . . . . . . . . . . . . . . . . 175 12-1 timer block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .179 12-2 i/o register summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .180 12-3 channel 7 output compare/pulse accumulator logic . . . . . .188 12-4 timer ic/oc select register (tios) . . . . . . . . . . . . . . . . . . .188 12-5 timer compare force register (cforc) . . . . . . . . . . . . . . .189 12-6 timer output compare 7 mask register (oc7m) . . . . . . . . .189 12-7 timer output compare 7 data register (oc7d) . . . . . . . . . .190 12-8 timer counter register high (tcnth) . . . . . . . . . . . . . . . . .191 12-9 timer counter register low (tcntl) . . . . . . . . . . . . . . . . . .191 12-10 timer system control register (tscr) . . . . . . . . . . . . . . . . .192 12-11 fast clear flag logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .193 12-12 timer control register 1 (tctl1) . . . . . . . . . . . . . . . . . . . . .194 12-13 timer control register 2 (tctl2) . . . . . . . . . . . . . . . . . . . . .194 12-14 timer control register 3 (tctl3) . . . . . . . . . . . . . . . . . . . . .195 12-15 timer control register 4 (tctl4) . . . . . . . . . . . . . . . . . . . . .195 12-16 timer mask 1 register (tmsk1) . . . . . . . . . . . . . . . . . . . . . .196 12-17 timer mask 2 register (tmsk2) . . . . . . . . . . . . . . . . . . . . . .196 12-18 timer flag register 1 (tflg1). . . . . . . . . . . . . . . . . . . . . . . .198 12-19 timer flag register 2 (tflg2). . . . . . . . . . . . . . . . . . . . . . . .198 12-20 timer channel registers (tcxh/l) . . . . . . . . . . . . . . . . . . . .199 12-21 pulse accumulator control register (pactl) . . . . . . . . . . . .200 12-22 pulse accumulator flag register (paflg) . . . . . . . . . . . . . .202 12-23 pulse accumulator counter registers (pacnth/l). . . . . . . .203 12-24 timer test register (timtst) . . . . . . . . . . . . . . . . . . . . . . . .204 12-25 timer port data register (portt) . . . . . . . . . . . . . . . . . . . .208 12-26 timer port data direction register (ddrt) . . . . . . . . . . . . . .209 12-27 example waveform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .210
list of figures advance information MC68HC812A4 ? rev. 5.0 motorola list of figures 25 figure title page 13-1 multiple serial interface block diagram . . . . . . . . . . . . . . . . .215 13-2 msi register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .216 13-3 port s data register (ports) . . . . . . . . . . . . . . . . . . . . . . . .219 13-4 port s data direction register (ddrs) . . . . . . . . . . . . . . . . . 220 13-5 spi control register 2 (sp0cr2). . . . . . . . . . . . . . . . . . . . . .221 14-1 sci block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .226 14-2 sci register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .227 14-3 sci data formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .229 14-4 sci transmitter block diagram . . . . . . . . . . . . . . . . . . . . . . .232 14-5 sci receiver block diagram . . . . . . . . . . . . . . . . . . . . . . . . .236 14-6 receiver data sampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . .238 14-7 start bit search example 1. . . . . . . . . . . . . . . . . . . . . . . . . . .240 14-8 start bit search example 2. . . . . . . . . . . . . . . . . . . . . . . . . . .240 14-9 start bit search example 3. . . . . . . . . . . . . . . . . . . . . . . . . . .241 14-10 start bit search example 4. . . . . . . . . . . . . . . . . . . . . . . . . . .241 14-11 start bit search example 5. . . . . . . . . . . . . . . . . . . . . . . . . . .242 14-12 start bit search example 6. . . . . . . . . . . . . . . . . . . . . . . . . . .242 14-13 slow data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .243 14-14 fast data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .244 14-15 single-wire operation (loops = 1 and rsrc = 1) . . . . . . .247 14-16 loop operation (loop = 1 and rsrc = 0) . . . . . . . . . . . . . .248 14-17 sci baud rate register high (sc0bdh or sc1bdh) . . . . . .249 14-18 sci baud rate register low (sc0bdl or sc1bdl) . . . . . . .249 14-19 sci control register 1 (sc0cr1 or sc1cr1). . . . . . . . . . . . 250 14-20 sci control register 2 (sc0cr2 or sc1cr2). . . . . . . . . . . . 252 14-21 sci status register 1 (sc0sr1 or sc1sr1). . . . . . . . . . . . .254 14-22 sci status register 2 (sc0sr2 or sc1sr2). . . . . . . . . . . . .256 14-23 sci data register high (sc0drh or sc1drh) . . . . . . . . . . 257 14-24 sci data register low (sc0drl or sc1drl) . . . . . . . . . . .257 15-1 spi block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .265 15-2 spi register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .266 15-3 full-duplex master/slave connections. . . . . . . . . . . . . . . . . .267
MC68HC812A4 ? rev. 5.0 advance information 26 list of figures motorola list of figures figure title page 15-4 transmission format 0 (cpha = 0) . . . . . . . . . . . . . . . . . . . .269 15-5 slave ss toggling when cpha = 0. . . . . . . . . . . . . . . . . . . . 269 15-6 transmission format 1 (cpha = 1) . . . . . . . . . . . . . . . . . . . .270 15-7 slave ss when cpha = 1 . . . . . . . . . . . . . . . . . . . . . . . . . . .270 15-8 single-wire operation (spc0 = 1) . . . . . . . . . . . . . . . . . . . . .272 15-9 spi control register 1 (sp0cr1). . . . . . . . . . . . . . . . . . . . . .273 15-10 spi control register 2 (sp0cr2). . . . . . . . . . . . . . . . . . . . . .275 15-11 spi baud rate register (sp0br) . . . . . . . . . . . . . . . . . . . . .276 15-12 spi status register (sp0sr) . . . . . . . . . . . . . . . . . . . . . . . . .277 15-13 spi data register (sp0dr) . . . . . . . . . . . . . . . . . . . . . . . . . .278 16-1 atd block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .287 16-2 atd i/o register summary . . . . . . . . . . . . . . . . . . . . . . . . . .288 16-3 atd control register 0 (atdctl0) . . . . . . . . . . . . . . . . . . . .291 16-4 atd control register 1 (atdctl1) . . . . . . . . . . . . . . . . . . . .291 16-5 atd control register 2 (atdctl2) . . . . . . . . . . . . . . . . . . . .292 16-6 atd control register 3 (atdctl3) . . . . . . . . . . . . . . . . . . . .293 16-7 atd control register 4 (atdctl4) . . . . . . . . . . . . . . . . . . . .294 16-8 atd control register 5 (atdctl5) . . . . . . . . . . . . . . . . . . . .296 16-9 atd status register 1 (atdstat1) . . . . . . . . . . . . . . . . . . .298 16-10 atd status register 2 (atdstat2) . . . . . . . . . . . . . . . . . . .298 16-11 atd test register 1 (atdtest1) . . . . . . . . . . . . . . . . . . . . .299 16-12 atd test register 2 (atdtest2) . . . . . . . . . . . . . . . . . . . . .299 16-13 atd result registers (adr0h ? adr7h) . . . . . . . . . . . . . . . . 300 16-14 port ad data input register (portad). . . . . . . . . . . . . . . . .302 17-1 bdm host-to-target serial bit timing . . . . . . . . . . . . . . . . . .309 17-2 bdm target-to-host serial bit timing (logic 1) . . . . . . . . . . .310 17-3 bdm target-to-host serial bit timing (logic 0) . . . . . . . . . . .310 17-4 bdm instruction register (instruction) . . . . . . . . . . . . . . 314 17-5 bdm instruction register (instruction) . . . . . . . . . . . . . . 315 17-6 bdm status register (status). . . . . . . . . . . . . . . . . . . . . . .317 17-7 bdm shift register (shifter) . . . . . . . . . . . . . . . . . . . . . . .318
list of figures advance information MC68HC812A4 ? rev. 5.0 motorola list of figures 27 figure title page 17-8 bdm address register (address) . . . . . . . . . . . . . . . . . . . 318 17-9 bdm ccr holding register (ccrsav) . . . . . . . . . . . . . . . . . 319 18-1 timer inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .329 18-2 por and external reset timing diagram . . . . . . . . . . . . . . .330 18-3 stop recovery timing diagram . . . . . . . . . . . . . . . . . . . . . .331 18-4 wait recovery timing diagram . . . . . . . . . . . . . . . . . . . . . .332 18-5 interrupt timing diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . .332 18-6 port read timing diagram . . . . . . . . . . . . . . . . . . . . . . . . . . .333 18-7 port write timing diagram . . . . . . . . . . . . . . . . . . . . . . . . . . .333 18-8 non-multiplexed expansion bus timing diagram . . . . . . . . .335 18-9 spi timing diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .337
MC68HC812A4 ? rev. 5.0 advance information 28 list of figures motorola list of figures
advance information MC68HC812A4 ? rev. 5.0 motorola list of tables 29 advance information ? MC68HC812A4 list of tables table title page 1-1 ordering information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33 1-2 pin descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 1-3 port descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38 1-4 port pullup, pulldown, and reduced drive summary . . . . . . .39 3-1 addressing mode summary . . . . . . . . . . . . . . . . . . . . . . . . . . .67 3-2 summary of indexed operations . . . . . . . . . . . . . . . . . . . . . . .68 4-1 interrupt vector map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .73 4-2 stacking order on entry to interrupts . . . . . . . . . . . . . . . . . . . .80 5-1 mode selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82 5-2 mapping precedence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .86 6-1 access type versus bus control pins . . . . . . . . . . . . . . . . . . .96 7-1 4-kbyte eeprom block protection . . . . . . . . . . . . . . . . . . . .117 7-2 erase selection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119 8-1 memory expansion values . . . . . . . . . . . . . . . . . . . . . . . . . . .125 8-2 example register settings . . . . . . . . . . . . . . . . . . . . . . . . . . .127 8-3 example register settings . . . . . . . . . . . . . . . . . . . . . . . . . . .130 8-4 stretch bit definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .142 8-5 module priorities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .142 10-1 clock monitor timeouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . .159 10-2 real-time interrupt rates . . . . . . . . . . . . . . . . . . . . . . . . . . .164 10-3 cop watchdog rates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .167 11-1 pll filter values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .171 11-2 base clock selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
MC68HC812A4 ? rev. 5.0 advance information 30 list of tables motorola list of tables table title page 11-3 module clock selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . .176 12-1 selection of output compare action . . . . . . . . . . . . . . . . . . .194 12-2 input capture edge selection. . . . . . . . . . . . . . . . . . . . . . . . .195 12-3 prescaler selection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .197 12-4 clock selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 12-5 timer interrupt sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . .207 12-6 timport i/o function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .208 13-1 port s pullup and reduced drive enable. . . . . . . . . . . . . . . .221 13-2 port s wired-or mode enable. . . . . . . . . . . . . . . . . . . . . . . .222 14-1 example 8-bit data formats. . . . . . . . . . . . . . . . . . . . . . . . . .229 14-2 example 9-bit data formats. . . . . . . . . . . . . . . . . . . . . . . . . .230 14-3 baud rates (module clock = 10.2 mhz) . . . . . . . . . . . . . . . .231 14-4 start bit verification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .238 14-5 data bit recovery. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .239 14-6 stop bit recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .239 14-7 loop mode functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .251 14-8 sci interrupt sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .260 15-1 ss pin configurations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .271 15-2 single-wire operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .275 15-3 spi clock rate selection . . . . . . . . . . . . . . . . . . . . . . . . . . . .276 15-4 spi interrupt sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .281 16-1 atd response to background debug enable . . . . . . . . . . . .294 16-2 final sample time selection . . . . . . . . . . . . . . . . . . . . . . . . .294 16-3 clock prescaler values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .295 16-4 multichannel mode result register assignment . . . . . . . . . .297 16-5 spi interrupt sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .302 17-1 ipipe decoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .306 17-2 bdm commands implemented in hardware . . . . . . . . . . . . .312 17-3 bdm firmware commands . . . . . . . . . . . . . . . . . . . . . . . . . .313 17-4 ttago decoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .316 17-5 regn decoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .316
advance information MC68HC812A4 ? rev. 5.0 motorola general description 31 advance information ? MC68HC812A4 section 1. general description 1.1 contents 1.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31 1.3 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32 1.4 ordering information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33 1.5 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 1.6 signal descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35 1.2 introduction the MC68HC812A4 microcontroller unit (mcu) is a 16-bit device composed of standard on-chip peripheral modules connected by an intermodule bus. modules include:  16-bit central processor unit (cpu12)  lite integration module (lim)  two asynchronous serial communications interfaces (sci0 and sci1)  serial peripheral interface (spi)  timer and pulse accumulator module  8-bit analog-to-digital converter (atd)  1-kbyte random-access memory (ram)  4-kbyte electrically erasable, programmable read-only memory (eeprom)  memory expansion logic with chip selects, key wakeup ports, and a phase-locked loop (pll)
MC68HC812A4 ? rev. 5.0 advance information 32 general description motorola general description 1.3 features features of the MC68HC812A4 include:  low-power, high-speed m68hc12 cpu  power-saving stop and wait modes  memory: ? 1024-byte ram ? 4096-byte eeprom ? on-chip memory mapping allows expansion to more than 5-mbyte address space  single-wire background debug ? mode  non-multiplexed address and data buses  seven programmable chip-selects with clock stretching (expanded modes)  8-channel, enhanced 16-bit timer with programmable prescaler: ? all channels configurable as input capture or output compare ? flexible choice of clock source  16-bit pulse accumulator  real-time interrupt circuit  computer operating properly (cop) watchdog  clock monitor  phase-locked loop (pll)  two enhanced asynchronous non-return-to-zero (nrz) serial communication interfaces (sci)  enhanced synchronous serial peripheral interface (spi)  8-channel, 8-bit analog-to-digital converter (atd)  up to 24 key wakeup lines with interrupt capability  available in 112-lead low-profile quad flat pack (lqfp) packaging ? background debug is a registered trademark of motorola, inc.
general description ordering information advance information MC68HC812A4 ? rev. 5.0 motorola general description 33 1.4 ordering information the MC68HC812A4 is available in 112-lead low-profile quad flat pack (lqfp) packaging. operating temperature range and voltage requirements are specified when ordering the MC68HC812A4 device. refer to table 1-1 for part numbers. evaluation boards, assemblers, compilers, and debuggers are available from motorola and from third-party suppliers. an up-to-date list of products that support the m68hc12 family of microcontrollers can be found on the world wide web at this url: http://www.motorola.com/mcu/ documents to assist in product selection are available from the motorola literature distribution center or local motorola sales offices. table 1-1. ordering information order number temperature voltage frequency (mhz) range designator MC68HC812A4pv 0 to + 70 c ? 3.3 2.0
MC68HC812A4 ? rev. 5.0 advance information 34 general description motorola general description 1.5 block diagram figure 1-1. block diagram v rh v rl v dda v ssa port e / pu ddre port j / pu / pd d d r j port h / pu ddrh port c / pu ddrc port d / pu ddrd port t / pu port s / pu spi0 sci1 sci0 xirq irq /v pp r/w lstrb /taglo eclk ipipe0/moda ipipe1/modb arst periodic interrupt cop watchdog clock monitor interrupt block single-wire background debug module 1-kbyte sram 4-kbyte eeprom cpu12 port ad ddrt tim oc7 ddrs msi ddrf port f / pu ddrg port g / pu ddra port a / pu ddrb port b / pu lim lite integration module lmb ? lite module bus pll clock control rxd0 txd0 rxd1 txd1 sdi/miso sdo/mosi sck bkgd/taghi reset extal xtal xfc v ddpll v sspll kwj7 kwj6 kwj5 kwj4 kwj3 kwj2 kwj1 kwj0 kwh7 kwh6 kwh5 kwh4 kwh3 kwh2 kwh1 kwh0 data15 data14 data13 data12 data11 data10 data9 data8 data7/kwd7 data6/kwd6 data5/kwd5 data4/kwd4 data3/kwd3 data2/kwd2 data1/kwd1 data0/kwd0 pd7 pd6 pd5 pd4 pd3 pd2 pd1 pd0 addr7 addr6 addr5 addr4 addr3 addr2 addr1 addr0 non-multiplexed address/data bus addr15 addr14 addr13 addr12 addr11 addr10 addr9 addr8 addr21 addr20 addr19 addr18 addr17 addr16 cs0 cs1 cs2 cs3 csd csp0 csp1 pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 pa7 pa6 pa5 pa4 pa3 pa2 pa1 pa0 pg5 pg4 pg3 pg2 pg1 pg0 pf6 pf5 pf4 pf3 pf2 pf1 pf0 v dd x1 v ssi x1 v ddext x3 v ssext x3 ps7 ps6 ps5 ps4 ps3 ps2 ps1 ps0 pt7 pt6 pt5 pt4 pt3 pt2 pt1 pt0 ioc6 ioc5 ioc4 ioc3 ioc2 ioc1 ioc0 ioc7/pai pad7v stby pad6 pad5 pad4 pad3 pad2 pad1 pad0 a/d converter v rh v rl v dda v ssa v stby /an7 an6 an5 an4 an3 an2 an1 an0 pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 ph7 ph6 ph5 ph4 ph3 ph2 ph1 ph0 pj7 pj6 pj5 pj4 pj3 pj2 pj1 pj0 pe7 pe6 pe5 pe4 pe3 pe2 pe1 pe0 ss
general description signal descriptions advance information MC68HC812A4 ? rev. 5.0 motorola general description 35 1.6 signal descriptions note: a line over a signal name indicates an active low signal. for example, reset is active high and reset is active low. the MC68HC812A4 is available in a 112-lead low-profile quad flat pack (lqfp). the pin assignments are shown in figure 1-2 . most pins perform two or more functions, as described in table 1-2 . individual ports are cross referenced in table 1-3 and table 1-4 . figure 1-2. pin assignments 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 v ssx v ddx kwj0/pj0 kwj1/pj1 kwj2/pj2 kwj3/pj3 kwj4/pj4 kwj5/pj5 kwj6/pj6 kwj7/pj7 addr16/pg0 addr17/pg1 addr18/pg2 v dd v ss addr19/pg3 addr20/pg4 addr21/pg5 bkgd / taghi data0/kwd0/pd0 data1/kwd1/pd1 data2/kwd2/pd2 data3/kwd3/pd3 data4/kwd4/pd4 data5/kwd5/pd5 data6/kwd6/pd6 data7/kwd7/pd7 data8/pc0 MC68HC812A4 112-lead lqfp 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 data9/pc1 data10/pc2 data11/pc3 data12/pc4 data13/pc5 data14/pc6 data15/pc7 xirq /pe0 irq /v pp / pe1 r/w/ pe2 lstrb /taglo /pe3 reset v ssx v ddx v ddpll xfc v sspll extal xtal eclk/pe4 moda/ipipe0/pe5 modb/ipipe1/pe6 arst/pe7 addr0/pb0 addr1/pb1 addr2/pb2 addr3/pb3 addr4/pb4 ph7/kwh7 ph6/kwh6 ph5/kwh5 ph4/kwh4 v ssx v ddx ph3/kwh3 ph2/kwh2 ph1/kwh1 ph0/kwh0 pf6/csp1 pf5/csp0 pf4/csd pf3/cs3 pf2/cs2 pf1/cs1 pf0/cs0 pa7/addr15 pa6/addr14 pa5/addr13 pa4/addr12 pa3/addr11 pa2/addr10 pa1/addr9 pa0/addr8 pb7/addr7 pb6/addr6 pb5/addr5 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 pt7/ioc7/pai pt6/ioc6 pt5/ioc5 pt4/ioc4 pt3/ioc3 pt2/ioc2 pt1/ioc1 pt0/ioc0 ps7/ss ps6/sck ps5/sdo/mosi ps4/sdi/miso ps3/txd1 ps2/rxd1 ps1/txd0 ps0/rxd0 v ssa v dda pad7/an7/v stby pad6/an6 pad5/an5 pad4/an4 pad3/an3 pad2/an2 pad1/an1 pad0/an0 v rl v rh 112 111 110 109 108 107 106 105 104 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85
MC68HC812A4 ? rev. 5.0 advance information 36 general description motorola general description table 1-2. pin descriptions pin port description v dd , v ss ? operating voltage and ground for the mcu (1) v rh , v rl ? reference voltages for the adc av dd , av ss ? operating voltage and ground for the adc (2) v ddpll , v sspll ? power and ground for pll clock control v stby port ad ram standby power input xtal, extal ? input pins for either a crystal or a cmos compatible clock (3) xirq pe0 asynchronous, non-maskable external interrupt request input irq pe1 asynchronous, maskable external interrupt request input with selectable falling-edge triggering or low-level triggering r/w pe2 expansion bus data direction indicator general-purpose i/o; read/write in expanded modes lstrb pe3 low byte strobe (0 = low byte valid) (4) general-purpose i/o eclk pe4 timing reference output for external bus clock (normally, half the crystal frequency) general-purpose i/o bkgd ? mode-select pin determines initial operating mode of the mcu after reset moda pe5 mode-select input determines initial operating mode of the mcu after reset (5) modb pe6 mode-select input determines initial operating mode of the mcu after reset (5) ipipe0 pe5 instruction queue tracking signals for development systems ipipe1 pe6 arst pe7 alternate active-high reset input general-purpose i/o xfc ? loop filter pin for controlled damping of pll vco loop reset ? active-low bidirectional control signal; input initializes mcu to known startup state; output when cop or clock monitor causes a reset addr15 ? addr8 port a single-chip modes: general-purpose i/o expanded modes: external bus pins port d in narrow data bus mode: general-purpose i/o or key wakeup port addr7 ? addr0 port b data15 ? data8 port c data7 ? data0 port d
general description signal descriptions advance information MC68HC812A4 ? rev. 5.0 motorola general description 37 addr21 ? addr16 port g memory expansion and general-purpose i/o cs3 ? cs0 ,csd , csp1 , csp0 port f chip selects general-purpose i/o bkgd ? single-wire background debug pin mode-select pin that determines special or normal operating mode after reset kwd7 ? kwd0 port d key wakeup pins that can generate interrupt requests on high-to-low transitions general-purpose i/o kwh7 ? kwh0 port h kwj7 ? kwj0 port j key wakeup pins that can generate interrupt requests on any transition general-purpose i/o rxd0 ps0 receive pin for sci0 txd0 ps1 transmit pin for sci0 rxd1 ps2 receive pin for sci1 txd1 ps3 transmit pin for sci1 sdi/miso ps4 master in/slave out pin for spi sdo/mosi ps5 master out/slave in pin for spi sck ps6 serial clock for spi ss ps7 slave select output for spi in master mode; slave select input in slave mode ioc7 ? ioc0 port t input capture or output compare channels and pulse accumulator input 1. the mcu operates from a single power supply. use the customary bypass techniques as very fast signal transitions occur on mcu pins. 2. separate power supply pins allow the adc power supply to be bypassed independently of the mcu power supply. 3. out of reset the frequency applied to extal is twice the desired e-clock rate. on reset all device clocks are derived from the extal input frequency. xtal is the crystal output. 4. lstrb is the exclusive-nor of a0 and the internal sz8 signal. sz8 indicates the size 16/8 access. 5. after reset, moda and modb can be configured as instruction queue tracking signals ipipe0 and ipipe1 or as gener- al-purpose i/o pins. table 1-2. pin descriptions (continued) pin port description
MC68HC812A4 ? rev. 5.0 advance information 38 general description motorola general description table 1-3. port descriptions port direction function port a i/o single-chip modes: general-purpose i/o expanded modes: external address bus addr15 ? addr8 port b i/o single-chip modes: general-purpose i/o expanded modes: external address bus addr7 ? addr0 port c i/o single-chip modes: general-purpose i/o expanded wide modes: external data bus data15 ? data8 expanded narrow modes: external data bus data15 ? data8/data7 ? data0 port d i/o single-chip and expanded narrow modes: general-purpose i/o external data bus data7 ? data0 in expanded wide mode (1) port e i/o and i (2) external interrupt request inputs, mode select inputs, bus control signals general-purpose i/o port f i/o chip select general-purpose i/o port g i/o memory expansion general-purpose i/o port h i/o key wakeup (3) general-purpose i/o port j i/o key wakeup (4) general-purpose i/o port s i/o sci and spi ports general-purpose i/o port t i/o timer port general-purpose i/o port ad i adc port general-purpose input 1. key wakeup interrupt request can occur when an input goes from high to low. 2. pe1 and pe0 are input-only pins. 3. key wakeup interrupt request can occur when an input goes from high to low. 4. key wakeup interrupt request can occur when an input goes from high to low or from low to high.
general description signal descriptions advance information MC68HC812A4 ? rev. 5.0 motorola general description 39 table 1-4. port pullup, pulldown, and reduced drive summary enable bit reduced drive control bit port name resistive input loads register (address) bit name reset state register (address) bit name reset state port a pullup pucr ($000c) pupa enabled rdriv ($000d) rdpab full drive port b pullup pucr ($000c) pupb enabled rdriv ($000d) rdpab full drive port c pullup pucr ($000c) pupc enabled rdriv ($000d) rdpc full drive port d pullup pucr ($000c) pupd enabled rdriv ($000d) rdpd full drive port e: pe7, pe3, pe2, pe0 pullup pucr ($000c) pupe enabled rdriv ($000d) rdpe full drive port e: pe1 pullup always enabled rdriv ($000d) rdpe full drive port e: pe4 none ? rdriv ($000d) rdpe full drive port e: pe6 and pe5 pulldown enabled during reset ??? port f pullup pucr ($000c) pupf enabled rdriv ($000d) rdpf full drive port g pullup pucr ($000c) pupg enabled rdriv ($000d) rdpg full drive port h pullup pucr ($000c) puph enabled rdriv ($000d) rdph full drive port j pullup/down (1) pulej ($002e) pulej[7:0] disabled rdriv ($000d) rdpj full drive port s pullup sp0cr2 ($00d1) pups enabled sp0cr2 ($00d1) rds full drive port t pullup tmsk2 ($008d) pupt enabled tmsk2 ($008d) rdpt full drive port ad none ?? bkgd pullup ?? enabled ?? full drive 1. pullup or pulldown devices for each port j pin can be selected with the pupsj register ($002d). after reset, pulldowns are selected for all port j pins but must be enabled with pulej register.
MC68HC812A4 ? rev. 5.0 advance information 40 general description motorola general description figure 1-3. expanded wide mode sram expansion schematic (sheet 1 of 3) 75 76 77 78 81 82 83 84 ph0 ph1 ph2 ph3 ph4 ph5 ph6 ph7 87 88 89 90 91 92 93 94 pad0 pad1 pad2 pad3 pad4 pad5 pad6 pad7 MC68HC812A4 u1 pad0 pad1 pad2 pad3 pad4 pad5 pad6 pad7 ph0 ph1 ph2 ph3 ph4 ph5 ph6 ph7 ph[0..7] pad[0..7] 68 69 70 71 72 73 74 pf0/cs0 pf1/cs1 pf2/cs2 pf3/cs3 pf4/csd pf5/csp0 pf6/csp1 3 4 5 6 7 8 9 10 pj0/kwj0 pj1/kwj1 pj2/kwj2 pj3/kwj3 pj5/kwj4 pj5/kwj5 pj6/kwj6 pj7/kwj7 pj0 pj1 pj2 pj3 pj4 pj5 pj6 pj7 pf0 pf1 pf2 pf3 pf4 pf5 pf6 pf[0..7] pj[0..7] 105 106 107 108 109 110 111 112 pt0/ioc0 pt1/ioc1 pt2/ioc2 pt3/ioc3 pt4/ioc4 pt5/ioc5 pt6/ioc6 pt7/ioc7 pt0 pt1 pt2 pt3 pt4 pt5 pt6 pt7 a[0..21] pt[0..7] d[0..15] 11 12 13 16 17 18 pg0/addr16 pg1/addr17 pg2/addr18 pg3/addr19 pg4/addr20 pg5/addr21 a16 a17 a18 a19 a20 a21 52 53 54 55 56 57 58 59 pb0/addr00 pb1/addr01 pb2/addr02 pb3/addr03 pb4/addr04 pb5/addr05 pb6/addr06 pb7/addr07 a0 a1 a2 a3 a4 a5 a6 a7 20 21 22 23 24 25 26 27 pd0/kwd0/data0 pd1/kwd1/data1 pd2/kwd2/data2 pd3/kwd3/data3 pd4/kwd4/data4 pd5/kwd5/data5 pd6/kwd6/data6 pd7/kwd7/data7 d0 d1 d2 d3 d4 d5 d6 d7 28 29 30 31 32 33 34 35 pc0/data08 pc1/data09 pc2/data10 pc3/data11 pc4/data12 pc5/data13 pd6/data14 pc7/data15 d8 d9 d10 d11 d12 d13 d14 d15 60 61 62 63 64 65 66 67 pa0/addr08 pa1/addr09 pa2/addr10 pa3/addr11 pa4/addr12 pa5/addr13 pa6/addr14 pa7/addr15 a8 a9 a10 a11 a12 a13 a14 a15 97 98 99 100 101 102 103 104 ps0/rxd0 ps1/rxd0 ps2/txd1 ps3/txd12 ps4/sdi/miso ps5/sd0/mosi ps6/sck ps7/ss ps0 ps1 ps2 ps3 ps4 ps5 ps6 ps7 ps[0..7] 19 36 37 38 39 48 49 50 51 pe0/xirq pe1/irq pe2/r/w pe3/lstrb pe4/eclk pe5/moda pe6/modb pe7/arst pe0 pe1 pe2 pe3 pe4 pe5 pe6 pe7 pe[0..7] bkgd/taghi 1 41 44 43 45 40 47 46 v ssx0 v ssx1 xfc v ddpll v sspll reset xtal extal 14 15 42 79 v dd v ss v ddx0 v ddx1 4 3 sw dip-2 1 2 s1 pe5 pe6 v dd y1 c3 c4 r3 r2 r s reset v ss v dd jp2 1 2 3 4 5 6 1 2 3 4 5 6 s2 a4_reset header 6 1 mc34064 2 3 in gnd rset c9 0.1 f c8 0.1 f c7 0.1 f c6 1.0 f v dd 4.7 k ? 4.7 k ? v dd v dd c p c s u2 v ss
general description signal descriptions advance information MC68HC812A4 ? rev. 5.0 motorola general description 41 figure 1-3. expanded wide mode sram expansion schematic (sheet 2 of 3) figure 1-3. expanded wide mode sram expansion schematic (sheet 3 of 3) 27 26 25 24 21 20 19 18 a9 a10 a11 a12 a13 a14 a15 a16 a9 a10 a11 a12 a13 a14 a15 a16 d[0. . 15] 5 4 3 2 1 44 43 42 a1 a2 a3 a4 a5 a6 a7 a8 a1 a2 a3 a4 a5 a6 a7 a8 u4 idt71016 d8 d9 d10 d11 d12 d13 d14 d15 d0 d1 d2 d3 d4 d5 d6 d7 29 30 31 32 35 36 37 38 7 8 9 10 13 14 15 16 d8 d9 d10 d11 d12 d13 d14 d15 d0 d1 d2 d3 d4 d5 d6 d7 we cs ble bhe 17 16 40 39 pe2/r/w pf6/csp1 a0 pe3 v cc v ss 33 34 v cc pe[0. . 7] pf[0. . 7] a[0. . 21] 8 7 6 5 4 3 2 1 a8 a9 a10 a11 a12 a13 a14 a15 a8 a9 a10 a11 a12 a13 a14 a15 d[0. . 15] 25 24 23 22 21 20 19 18 a0 a1 a2 a3 a4 a5 a6 a7 a0 a1 a2 a3 a4 a5 a6 a7 u3 am29dl400b dq8 dq9 dq10 dq11 dq12 dq13 dq14 dq15 dq0 dq1 dq2 dq3 dq4 dq5 dq6 dq7 30 32 34 36 39 41 43 45 29 31 33 35 38 40 42 44 d8 d9 d10 d11 d12 d13 d14 d15 d0 d1 d2 d3 d4 d5 d6 d7 reset v cc v ss v ss1 12 37 27 46 byte# we 47 11 a[0. . 21] 48 17 a16 a17 a16 a17 reset v cc oe ce ry/by 15 28 26 pf[0. . 7] pe[0. . 7] v cc r5 resistor s3 mode_select pf5/csp0 pe2/r/w
MC68HC812A4 ? rev. 5.0 advance information 42 general description motorola general description figure 1-4. expanded narrow mode sram expansion schematic (sheet 1 of 3) 75 76 77 78 81 82 83 84 ph0 ph1 ph2 ph3 ph4 ph5 ph6 ph7 87 88 89 90 91 92 93 94 pad0 pad1 pad2 pad3 pad4 pad5 pad6 pad7 MC68HC812A4 u1 pad0 pad1 pad2 pad3 pad4 pad5 pad6 pad7 ph0 ph1 ph2 ph3 ph4 ph5 ph6 ph7 ph[0..7] pad[0..7] 68 69 70 71 72 73 74 pf0/cs0 pf1/cs1 pf2/cs2 pf3/cs3 pf4/csd pf5/csp0 pf6/csp1 3 4 5 6 7 8 9 10 pj0/kwj0 pj1/kwj1 pj2/kwj2 pj3/kwj3 pj5/kwj4 pj5/kwj5 pj6/kwj6 pj7/kwj7 pj0 pj1 pj2 pj3 pj4 pj5 pj6 pj7 pf0 pf1 pf2 pf3 pf4 pf5 pf6 pf[0..7] pj[0..7] 105 106 107 108 109 110 111 112 pt0/ioc0 pt1/ioc1 pt2/ioc2 pt3/ioc3 pt4/ioc4 pt5/ioc5 pt6/ioc6 pt7/ioc7 pt0 pt1 pt2 pt3 pt4 pt5 pt6 pt7 a[0..21] pt[0..7] d[0..15] 11 12 13 16 17 18 pg0/addr16 pg1/addr17 pg2/addr18 pg3/addr19 pg4/addr20 pg5/addr21 a16 a17 a18 a19 a20 a21 52 53 54 55 56 57 58 59 pb0/addr00 pb1/addr01 pb2/addr02 pb3/addr03 pb4/addr04 pb5/addr05 pb6/addr06 pb7/addr07 a0 a1 a2 a3 a4 a5 a6 a7 20 21 22 23 24 25 26 27 pd0/kwd0/data0 pd1/kwd1/data1 pd2/kwd2/data2 pd3/kwd3/data3 pd4/kwd4/data4 pd5/kwd5/data5 pd6/kwd6/data6 pd7/kwd7/data7 d0 d1 d2 d3 d4 d5 d6 d7 28 29 30 31 32 33 34 35 pc0/data08 pc1/data09 pc2/data10 pc3/data11 pc4/data12 pc5/data13 pd6/data14 pc7/data15 d8 d9 d10 d11 d12 d13 d14 d15 60 61 62 63 64 65 66 67 pa0/addr08 pa1/addr09 pa2/addr10 pa3/addr11 pa4/addr12 pa5/addr13 pa6/addr14 pa7/addr15 a8 a9 a10 a11 a12 a13 a14 a15 97 98 99 100 101 102 103 104 ps0/rxd0 ps1/rxd0 ps2/txd1 ps3/txd12 ps4/sdi/miso ps5/sd0/mosi ps6/sck ps7/ss ps0 ps1 ps2 ps3 ps4 ps5 ps6 ps7 ps[0..7] 19 36 37 38 39 48 49 50 51 pe0/xirq pe1/irq pe2/r/w pe3/lstrb pe4/eclk pe5/moda pe6/modb pe7/arst pe0 pe1 pe2 pe3 pe4 pe5 pe6 pe7 pe[0..7] bkgd/taghi 1 41 44 43 45 40 47 46 v ssx0 v ssx1 xfc v ddpll v sspll reset xtal extal 14 15 42 79 v dd v ss v ddx0 v ddx1 4 3 sw dip-2 1 2 s1 pe5 pe6 v dd y1 c3 c4 r3 r2 r s reset v ss v dd jp2 1 2 3 4 5 6 1 2 3 4 5 6 s2 a4_reset header 6 1 mc34064 2 3 in gnd rset c9 0.1 f c8 0.1 f c7 0.1 f c6 1.0 f v dd 4.7 k ? 4.7 k ? v dd v dd c p c s u2 v ss
general description signal descriptions advance information MC68HC812A4 ? rev. 5.0 motorola general description 43 figure 1-4. expanded narrow mode sram expansion schematic (sheet 2 of 3) figure 1-4. expanded narrow mode sram expansion schematic (sheet 3 of 3) 27 26 23 25 4 28 29 3 a8 a9 a10 a11 a12 a13 a14 a15 a8 a9 a10 a11 a12 a13 a14 a15 d[0. . 15] 12 11 10 9 8 7 6 5 a0 a1 a2 a3 a4 a5 a6 a7 a0 a1 a2 a3 a4 a5 a6 a7 u3 am27f010 d0 d1 d2 d3 d4 d5 d6 d7 13 14 15 17 18 19 20 21 d8 d9 d10 d11 d12 d13 d14 d15 ce oe we v pp 22 24 31 1 a[0. . 21] 2 a16 a16 pf[0. . 7] pe[0. . 7] pf5/csp0 pe2/r/w pe[0. . 7] 25 24 21 23 2 26 1 a8 a9 a10 a11 a12 a13 a14 a8 a9 a10 a11 a12 a13 a14 d[0. . 15] 10 9 8 7 6 5 4 3 a0 a1 a2 a3 a4 a5 a6 a7 a0 a1 a2 a3 a4 a5 a6 a7 u3 ds1230y d0 d1 d2 d3 d4 d5 d6 d7 11 12 13 15 16 17 18 19 d8 d9 d10 d11 d12 d13 d14 d15 ce we oe 20 27 22 a[0. . 21] pf6/csp1 pe2/r/w pf[0. . 7]
MC68HC812A4 ? rev. 5.0 advance information 44 general description motorola general description
advance information MC68HC812A4 ? rev. 5.0 motorola register block 45 advance information ? MC68HC812A4 section 2. register block 2.1 contents 1.2 overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 1.3 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46 1.4 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60 2.2 overview the register block can be mapped to any 2-kbyte boundary within the standard 64-kbyte address space by manipulating bits reg15 ? reg11 in the initrg register. initrg establishes the upper five bits of the register block ? s 16-bit address. the register block occupies the first 512 bytes of the 2-kbyte block. figure 2-1 shows the default addressing.
MC68HC812A4 ? rev. 5.0 advance information 46 register block motorola register block 2.3 register map addr.register name bit 7654321bit 0 $0000 port a data register (porta) see page 98. read: pa7 pa6 pa5 pa4 pa3 pa2 pa1 pa0 write: reset:00000000 $0001 port b data register (portb) see page 99. read: pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 write: reset:00000000 $0002 port a data direction register (ddra) see page 98. read: ddra7 ddra6 ddra5 ddra4 ddra3 ddra2 ddra1 ddra0 write: reset:00000000 $0003 port b data direction register (ddrb) see page 99. read: ddrb7 ddrb6 ddrb5 ddrb4 ddrb3 ddrb2 ddrb1 ddrb0 write: reset:00000000 $0004 port c data register (portc) see page 100. read: pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 write: reset:00000000 $0005 port d data register (portd) see page 102. read: pd7 pd6 pd5 pd4 pd3 pd2 pd1 pd0 write: reset:00000000 $0006 port c data direction register (ddrc) see page 101. read: ddrc7 ddrc6 ddrc5 ddrc4 ddrc3 ddrc2 ddrc1 ddrc0 write: reset:00000000 $0007 port d data direction register (ddrd) see page 103. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $0008 port e data register (porte) see page 104. read: pe7 pe6 pe5 pd4 pd3 pd2 pd1 pd0 write: reset:00001000 $0009 port e data direction register (ddre) see page 105. read: ddre7 ddre6 ddre5 ddre4 ddre3 ddre2 ddre1 ddre0 write: reset:00000011 = unimplemented r = reserved u = unaffected figure 2-1. register map (sheet 1 of 15)
register block register map advance information MC68HC812A4 ? rev. 5.0 motorola register block 47 $000a port e assignment register (pear) see page 106. read: arsie pllte pipoe neclk lstre rdwe 0 0 write: reset:00101100 $000b mode register (mode) see page 87. read: smodn modb moda estr ivis 0 emd eme write: reset:00011011 $000c pullup control register (pucr) see page 109. read: puph pupg pupf pupe pupd puc pupb pupa write: reset:11111111 $000d reduced drive register (rdriv) see page 110. read: rdpj rdph rdpg rdpf rdpe prpd rdpc rdpab write: reset:00000000 $000e reserved r r r r r r r r $000f reserved r r r r r r r r $0010 ram initialization register (initrm) see page 90. read: ram15 ram14 ram13 ram12 ram11 0 0 0 write: reset:00001000 $0011 register initialization register (initrg) see page 89. read: reg15 reg14 reg13 reg12 reg11 0 0 0 write: reset:00000000 $0012 eeprom initialization register (initee) see page 91. read: ee15 ee14 ee13 ee12 0 0 0 eeon write: reset:00010001 $0013 miscellaneous mapping control register (misc) see page 91. read: ewdir ndrc 0 0 0 0 0 0 write: reset:00000000 $0014 real-tme interrupt control reg. (rtictl) see page 163. read: rtie rswai rsbck 0 rtbyp rtr2 rtr1 rtr0 write: reset:00000000 $0015 real-time interrupt flag register (rtiflg) see page 165. read: rtif 0000000 write: reset:00000000 addr.register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected figure 2-1. register map (sheet 2 of 15)
MC68HC812A4 ? rev. 5.0 advance information 48 register block motorola register block $0016 cop control register (copctl) see page 165. read: cme fcme fcm fcop disr cr2 cr1 cr0 write: reset:00000111 $0017 arm/reset cop register (coprst) see page 168. read: 00000000 write: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 reset:00000000 $0018 reserved r r r r r r r r $001d reserved r r r r r r r r $001e interrupt control register (intcr) see page 75. read: irqe irqen dly 00000 write: reset:01100000 $001f highest priority i interrupt reg. (hprio) see page 76. read: 1 1 psel5 psel4 psel3 psel2 psel1 0 write: reset:11110010 $0020 port d key wakeup interrupt enable reg. (kwied) see page 147. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $0021 port d key wakeup flag register (kwifd) see page 148. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $0022 reserved r r r r r r r r $0023 reserved r r r r r r r r $0024 port h data register (porth) see page 148. read: ph7 ph6 ph5 ph4 ph3 ph2 ph1 ph0 write: reset:00000000 $0025 port h data direction register (ddrh) see page 149. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $0026 port h key wakeup interrupt enable reg. (kwieh) see page 149. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 addr.register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected figure 2-1. register map (sheet 3 of 15)
register block register map advance information MC68HC812A4 ? rev. 5.0 motorola register block 49 $0027 port h key wakeup flag register (kwifh) see page 150. read: kwifh7 kwifh6 kwifh5 kwifh4 kwifh3 kwifh2 kwifh1 kwifh0 write: reset:00000000 $0028 port j data register (portj) see page 150. read: pj7 pj6 pj5 pj4 pj3 pj2 pj1 pj0 write: reset:00000000 $0029 port j data direction register (ddrj) see page 151. read: ddrj7 ddrj6 ddrj5 ddrj4 ddrj3 ddrj2 ddrj1 ddrj0 write: reset:00000000 $002a port j key wakeup interrupt enable register (kwiej) see page 151. read: kwiej7 kwiej6 kwiej5 kwiej4 kwiej3 kwiej2 kwiej1 kwiej0 write: reset:00000000 $002b port j key wakeup flag register (kwifj) see page 152. read: kwifj7 kwifj6 kwifj5 kwifj4 kwifj3 kwifj2 kwifj1 kwifj0 write: reset:00000000 $002c port j key wakeup polarity register (kpolj) see page 152. read: kpolj7 kpolj6 kpolj5 kpolj4 kpolj3 kpolj2 kpolj1 kpolj0 write: reset:00000000 $002d port j key wakeup pullup/pulldown select register (pupsj) see page 153. read: pupsj7 pupsj6 pupsj5 pupsj4 pupsj3 pupsj2 pupsj1 pupsj0 write: reset:00000000 $002e port j key wakeup pullup/pulldown enable register (pulej) see page 154. read: pulej7 pulej6 pulej5 pulej4 pulej3 pulej2 pulej1 pulej0 write: reset:00000000 $002f reserved r r r r r r r r $0030 port f data register (portf) see page 132. read: 0 pf6 pf5 pf4 pf3 pf2 pf1 pf0 write: reset:00000000 $0031 port g data register (portg) see page 132. read: 0 0 bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 addr.register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected figure 2-1. register map (sheet 4 of 15)
MC68HC812A4 ? rev. 5.0 advance information 50 register block motorola register block $0032 port f data direction register (ddrf) see page 133. read: 0 ddrf6 ddrf5 ddrf4 ddrf3 ddrf2 ddrf1 ddrf0 write: reset:00000000 $0033 port g data direction register (ddrg) see page 133. read: 0 0 ddrg5 ddrg4 ddrg3 ddrg2 ddrg1 ddrg0 write: reset:00000000 $0034 data page register (dpage) see page 134. read: pd19 pd18 pd17 pd16 pd15 pd14 pd13 pd12 write: reset:00000000 $0035 program page register (ppage) see page 134. read: ppa21 ppa20 ppa19 ppa18 ppa17 ppa16 ppa15 ppa14 write: reset:00000000 $0036 extra page register (epage) see page 135. read: pea17 pea16 pea15 pea14 pea13 pea12 pea11 pea10 write: reset:00000000 $0037 window definition register (windef) see page 135. read: dwen pwen ewen 0 0 0 0 0 write: reset:00000000 $0038 memory expansion assignment register (mxar) see page 136. read: 0 0 a21e a20e a19e a18e a17e a16e write: reset:00000000 $0039 reserved r r r r r r r r $003a reserved r r r r r r r r $003b reserved r r r r r r r r $003c chip-select control register 0 (csctl0) see page 138. read: 0 csp1e csp0e csde cs3e cs2e cs1e cs0e write: reset:00000000 $003d chip-select control register 1 (csctl1) see page 140. read: 0 csp1fl cspa21 csdhf cs3ep 000 write: reset:00000000 $003e chip-select stretch register 0 (csstr0) see page 141. read: 0 0 srp1a srp1b srp0a srp0b strda strdb write: reset:00111111 addr.register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected figure 2-1. register map (sheet 5 of 15)
register block register map advance information MC68HC812A4 ? rev. 5.0 motorola register block 51 $003f chip-select stretch register 1 (csstr1) see page 141. read: str3a str3b str2a str2b str1a str1b str0a str0b write: reset:00111111 $0040 loop divider register high (ldvh) see page 173. read: 0000 ldv11 ldv10 ldv9 ldv8 write: reset:00001111 $0041 loop divider register low (ldvl) see page 173. read: ldv7 ldv6 ldv5 ldv4 ldv3 ldv2 ldv1 ldv0 write: reset:11111111 $0042 reference divider register high (rdvh) see page 174. read: 0000 rdv11 rdv10 rdv9 rdv8 write: reset:00001111 $0043 reference divider register low (rdvl) see page 174. read: rdv7 rdv6 rdv5 rdv4 rdv3 rdv2 rdv1 rdv0 write: reset:11111111 $0044 reserved r r r r r r r r $0045 reserved r r r r r r r r $0046 reserved r r r r r r r r $0047 clock control register (clkctl) see page 175. read: lckf pllon plls bcsc bcsb bcsa mcsb mcsa write: reset:00000000 $0048 reserved r r r r r r r r $005f reserved r r r r r r r r $0060 atd control register 0 (atdctl0) see page 291. read: 00000000 write: reset:00000000 $0061 atd control register 1 (atdctl1) see page 291. read: 00000000 write: reset:00000000 addr.register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected figure 2-1. register map (sheet 6 of 15)
MC68HC812A4 ? rev. 5.0 advance information 52 register block motorola register block $0062 atd control register 2 (atdctl2) see page 292. read: adpu affc awai 000 ascie ascif write: reset:00000000 $0063 atd control register 3 (atdctl3) see page 293. read: 000000 frz1 frz0 write: reset:00000000 $0064 atd control register 4 (atdctl4) see page 294. read: 0 smp1 smp0 prs4 prs3 prs2 prs1 prs0 write: reset:00000001 $0065 atd control register 5 (atdctl5) see page 296. read: 0 s8cm scan mult cd cc cb ca write: reset:00000000 $0066 atd status register 1 (atdstat1) see page 298. read: scf 0 0 0 0 cc2 cc1 cc0 write: reset:00000000 $0067 atd status register 2 (atdstat2) see page 298. read: ccf7 ccf6 ccf5 ccf4 ccf3 ccf2 ccf1 ccf0 write: reset:00000000 $0068 atd test register 1 (atdtest1) see page 299. read: sar9 sar8 sar7 sar6 sar5 sar4 sar3 sar2 write: reset:00000000 $0069 atd test register 2 (atdtest2) see page 299. read: sar1 sar0 rst tstout tst3 tst2 tst1 tst0 write: reset:00000000 $006a reserved r r r r r r r r $006e reserved r r r r r r r r $006f port ad data input register (portad) see page 302. read: pad7 pad6 pad5 pad4 pad3 pad2 pad1 pad0 write: reset:00000000 $0070 atd result register 0 (adr0h) see page 300. read: adrxh7 adrxh6 adrxh5 adrxh4 adrxh3 adrxh2 adrxh1 adrxh0 write: reset: indeterminate addr.register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected figure 2-1. register map (sheet 7 of 15)
register block register map advance information MC68HC812A4 ? rev. 5.0 motorola register block 53 $0071 reserved r r r r r r r r $0072 atd result register 1 (adr1h) see page 300. read: adrxh7 adrxh6 adrxh5 adrxh4 adrxh3 adrxh2 adrxh1 adrxh0 write: reset: indeterminate $0073 reserved r r r r r r r r $0074 atd result register 2 (adr2h) see page 300. read: adrxh7 adrxh6 adrxh5 adrxh4 adrxh3 adrxh2 adrxh1 adrxh0 write: reset: indeterminate $0075 reserved r r r r r r r r $0076 atd result register 3 (adr3h) see page 300. read: adrxh7 adrxh6 adrxh5 adrxh4 adrxh3 adrxh2 adrxh1 adrxh0 write: reset: indeterminate $0077 reserved r r r r r r r r $0078 atd result register 4 (adr4h) see page 300. read: adrxh7 adrxh6 adrxh5 adrxh4 adrxh3 adrxh2 adrxh1 adrxh0 write: reset: indeterminate $0079 reserved r r r r r r r r $007a atd result register 5 (adr5h) see page 300. read: adrxh7 adrxh6 adrxh5 adrxh4 adrxh3 adrxh2 adrxh1 adrxh0 write: reset: indeterminate $007b reserved r r r r r r r r $007c atd result register 6 (adr6h) see page 300. read: adrxh7 adrxh6 adrxh5 adrxh4 adrxh3 adrxh2 adrxh1 adrxh0 write: reset: indeterminate $007d reserved r r r r r r r r $007e atd result register 7 (adr7h) see page 300. read: adrxh7 adrxh6 adrxh5 adrxh4 adrxh3 adrxh2 adrxh1 adrxh0 write: reset: indeterminate $007f reserved r r r r r r r r addr.register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected figure 2-1. register map (sheet 8 of 15)
MC68HC812A4 ? rev. 5.0 advance information 54 register block motorola register block $0080 timer ic/oc select register (tios) see page 188. read: ios7 ios6 ios5 ios4 ios3 ios2 ios1 ios0 write: reset:00000000 $0081 timer compare force register (cforc) see page 189. read: foc7 foc6 foc5 foc4 foc3 foc2 foc1 foc0 write: reset:00000000 $0082 timer output compare 7 mask register (oc7m) see page 189. read: oc7m7 oc7m6 oc7m5 oc7m4 oc7m3 oc7m2 oc7m1 oc7m0 write: reset:00000000 $0083 timer output compare 7 data register (oc7d) see page 190. read: oc7d7 oc7d6 oc7d5 oc7d4 oc7d3 oc7d2 oc7d1 oc7d0 write: reset:00000000 $0084 timer counter register high (tcnth) see page 191. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $0085 timer counter register low (tcntl) see page 191. read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset:00000000 $0086 timer system control register (tscr) see page 192. read: ten tswai tsbck tffca 0000 write: reset:00000000 $0087 reserved r r r r r r r r $0088 timer control register 1 (tctl1) see page 194. read: om7ol7om6ol6om5ol5om4ol4 write: reset:00000000 $0089 timer control register 2 (tctl2) see page 194. read: om3ol3om2ol2om1ol1om0ol0 write: reset:00000000 $008a timer control register 3 (tctl3) see page 195. read: edg7b edg7a edg6b edg6a edg5b edg5a edg4b edg4a write: reset:00000000 addr.register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected figure 2-1. register map (sheet 9 of 15)
register block register map advance information MC68HC812A4 ? rev. 5.0 motorola register block 55 $008b timer control register 4 (tctl4) see page 195. read: edg3b edg3a edg2b edg2a edg1b edg1a edg0b edg0a write: reset:00000000 $008c timer mask register 1 (tmsk1) see page 196. read: c7i c6i c5i c4i c3i c2i c1i c0i write: reset:00000000 $008d timer mask register 2 (tmsk2) see page 196. read: toi 0 pupt rdpt tcre pr2 pr1 pr0 write: reset:00110000 $008e timer flag register 1 (tflg1) see page 198. read: c7f c6f c5f c4f c3f c2f c1f c0f write: reset:00000000 $008f timer flag register 2 (tflg2) see page 198. read: tof 0000000 write: reset:00000000 $0090 timer channel 0 register high (tc0h) see page 199. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $0091 timer channel 0 register low (tc0l) see page 199. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $0092 timer channel 1 register high (tc1h) see page 199. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $0093 timer channel 1 register low (tc1l) see page 199. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $0094 timer channel 2 register high (tc2h) see page 199. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $0095 timer channel 2 register low (tc2l) see page 199. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 addr.register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected figure 2-1. register map (sheet 10 of 15)
MC68HC812A4 ? rev. 5.0 advance information 56 register block motorola register block $0096 timer channel 3 register high (tc3h) see page 199. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $0097 timer channel 3 register low (tc3l) see page 199. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $0098 timer channel 4 register high (tc4h) see page 199. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $0099 timer channel 4 register low (tc4l) see page 199. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $009a timer channel 5 register high (tc5h) see page 199. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $009b timer channel 5 register low (tc5l) see page 199. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $009c timer channel 6 register high (tc6h) see page 199. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $009d timer channel 6 register low (tc6l) see page 199. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $009e timer channel 7 register high (tc7h) see page 199. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $009f timer channel 7 register low (tc7l) see page 199. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $00a0 pulse accumulator control register (pactl) see page 200. read: 0 paen pamod pedge clk1 clk0 paovi pai write: reset:00000000 addr.register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected figure 2-1. register map (sheet 11 of 15)
register block register map advance information MC68HC812A4 ? rev. 5.0 motorola register block 57 $00a1 pulse accumulator flag register (paflg) see page 202. read: bit 0 0 0 0 0 0 paovf paif write: reset:00000000 $00a2 pulse accumulator counter register high (pacnth) see page 203. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $00a3 pulse accumulator counter register low (pacntl) see page 203. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $00a4 reserved r r r r r r r r $00ac reserved r r r r r r r r $00ad timer test register (timtst) see page 204. read: 000000tcbyppcbyp write: reset:00000000 $00ae timer port data register (portt) see page 208. read: pt7pt6pt5pt4pt3pt2pt1pt0 write: reset: unaffected by reset $00af timer port data direction register (ddrt) see page 209. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $00b0 reserved r r r r r r r r $00bf reserved r r r r r r r r $00c0 sci 0 baud rate register high (sc0bdh) see page 249. read: btst bspl brld sbr12 sbr11 sbr10 sbr9 sbr8 write: reset:00000000 $00c1 sci 0 baud rate register low (sc0bdl) see page 249. read: sbr7 sbr6 sbr5 sbr4 sbr3 sbr2 sbr1 sbr0 write: reset:00000100 addr.register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected figure 2-1. register map (sheet 12 of 15)
MC68HC812A4 ? rev. 5.0 advance information 58 register block motorola register block $00c2 sci 0 control register 1 (sc0cr1) see page 250. read: loops woms rsrc m wake ilt pe pt write: reset:00000000 $00c3 sci 0 control register 2 (sc0cr2) see page 252. read: tie tcie rie ilie te re rwu sbk write: reset:00000000 $00c4 sci 0 status register 1 (sc0sr1) see page 254. read: tdre tc rdrf idle or nf fe pf write: reset:11000000 $00c5 sci 0 status register 2 (sc0sr2) see page 256. read: 0000000raf write: reset:00000000 $00c6 sci 0 data register high (sc0drh) see page 257. read: r8 t8 000000 write: reset: unaffected by reset $00c7 sci 0 data register low (sc0drl) see page 257. read: r7 r6 r5 r4 r3 r2 r1 r0 write: t7 t6 t5 t4 t3 t2 t1 t0 reset: unaffected by reset $00c8 sci 1 baud rate register high (sc1bdh) see page 249. read: btst bspl brld sbr12 sbr11 sbr10 sbr9 sbr8 write: reset:00000000 $00c9 sci 1 baud rate register low (sc1bdl) see page 249. read: sbr7 sbr6 sbr5 sbr4 sbr3 sbr2 sbr1 sbr0 write: reset:00000100 $00ca sci 1 control register 1 (sc1cr1) see page 250. read: loops woms rsrc m wake ilt pe pt write: reset:00000000 $00cb sci 1 control register 2 (sc1cr2) see page 252. read: tie tcie rie ilie te re rwu sbk write: reset:00000000 $00cc sci 1 status register 1 (sc1sr1) see page 254. read: tdre tc rdrf idle or nf fe pf write: reset:11000000 addr.register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected figure 2-1. register map (sheet 13 of 15)
register block register map advance information MC68HC812A4 ? rev. 5.0 motorola register block 59 $00cd sci 1 status register 2 (sc1sr2) see page 256. read: 0000000raf write: reset:00000000 $00ce sci 1 data register high (sc1drh) see page 257. read: r8 t8 000000 write: reset: unaffected by reset $00cf sci 1 data register low (sc1drl) see page 257. read: r7 r6 r5 r4 r3 r2 r1 r0 write: t7 t6 t5 t4 t3 t2 t1 t0 reset: unaffected by reset $00d0 spi 0 control register 1 (sp0cr1) see page 273. read: spie spe swom mstr cpol cpha ssoe lsbf write: reset:00000100 $00d1 spi 0 control register 2 (sp0cr2) see page 275. read: 0000 pups rds 0 spc0 write: reset:00001000 $00d2 spi baud rate register (sp0br) see page 276. read: 00000 spr2 spr1 spr0 write: reset:00000000 $00d3 spi status register (sp0sr) see page 277. read: spif wcol 0 modf 0 0 0 0 write: reset:00000000 $00d4 reserved r r r r r r r r $00d5 spi data register (sp0dr) see page 278. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset: unaffected by reset $00d6 port s data register (ports) see page 219. read: ps7 ps6 ps5 ps4 ps3 ps2 ps1 ps0 write: reset: unaffected by reset $00d7 port s data direction register (ddrs) see page 220. read: ddrs7 ddrs6 ddrs5 ddrs4 ddrs3 ddrs2 ddrs1 ddrs0 write: reset: 0 0000000 addr.register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected figure 2-1. register map (sheet 14 of 15)
MC68HC812A4 ? rev. 5.0 advance information 60 register block motorola register block 2.4 modes of operation porta, portb, portc, and data direction registers ddra, ddrb, and ddrc are not in the map in expanded and peripheral modes. pear, mode, pucr, and rdriv are not in the map in peripheral mode. when emd is set:  portd and ddrd are not the map in wide expanded modes, peripheral mode, and narrow special expanded mode.  porte and ddre are not in the map in peripheral mode and expanded modes.  kwied and kwifd are not in the map in wide expanded modes and narrow special expanded mode. $00d8 reserved r r r r r r r r $00ef reserved r r r r r r r r $00f0 eeprom configuration register (eemcr) see page 116. read: 11111eeswaiprotlckeerc write: reset:11111100 $00f1 eeprom block protect register (eeprot) see page 117. read: 1 bprot6 bprot5 bprot4 bprot3 bprot2 bprot1 bprot0 write: reset:11111111 $00f2 eeprom test register (eetst) see page 118. read: eeodd eeven marg eecpd eecprd 0 eecpm 0 write: reset:00000000 $00f3 eeprom programming register (eeprog) see page 119. read: bulkp 0 0 byte row erase eelat eepgm write: reset:10000000 $00f4 reserved r r r r r r r r $01ff reserved r r r r r r r r addr.register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected figure 2-1. register map (sheet 15 of 15)
advance information MC68HC812A4 ? rev. 5.0 motorola central processor unit (cpu12) 61 advance information ? MC68HC812A4 section 3. central processor unit (cpu12) 3.1 contents 1.2 overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 1.3 programming model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62 1.4 cpu registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 1.4.1 accumulators a and b . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63 1.4.2 accumulator d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63 1.4.3 index registers x and y. . . . . . . . . . . . . . . . . . . . . . . . . . . .64 1.4.4 stack pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 1.4.5 program counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65 1.4.6 condition code register . . . . . . . . . . . . . . . . . . . . . . . . . . .65 1.5 data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .66 1.6 addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67 1.7 indexed addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . .68 1.8 opcodes and operands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69 3.2 overview the cpu12 is a high-speed, 16-bit processor unit. it has full 16-bit data paths and wider internal registers (up to 20 bits) for high-speed extended math instructions. the instruction set is a proper superset of the m68hc11instruction set. the cpu12 allows instructions with odd byte counts, including many single-byte instructions. this provides efficient use of rom space. an instruction queue buffers program information so the cpu always has immediate access to at least three bytes of machine code at the start of every instruction. the cpu12 also offers an extensive set of indexed addressing capabilities.
MC68HC812A4 ? rev. 5.0 advance information 62 central processor unit (cpu12) motorola central processor unit (cpu12) 3.3 programming model cpu12 registers are an integral part of the cpu and are not addressed as if they were memory locations. see figure 3-1 . figure 3-1. programming model 3.4 cpu registers this section describes the cpu registers. 7 15 15 15 15 15 d x y sp pc ab n sxh i zvc 0 0 0 0 0 0 7 0 condition code register 8-bit accumulators a and b 16-bit double accumulator d (a : b) index register x index register y stack pointer program counter stop disable (ignore stop opcodes) carry overflow zero negative irq interrupt mask (disable) half-carry for bcd arithmetic xirq interrupt mask (disable)
central processor unit (cpu12) cpu registers advance information MC68HC812A4 ? rev. 5.0 motorola central processor unit (cpu12) 63 3.4.1 accumulators a and b accumulators a and b are general-purpose 8-bit accumulators that contain operands and results of arithmetic calculations or data manipulations. 3.4.2 accumulator d accumulator d is the concatenation of accumulators a and b. some instructions treat the combination of these two 8-bit accumulators as a 16-bit double accumulator. bit 7654321bit 0 a7 a6 a5 a4 a3 a2 a1 a0 reset: unaffected by reset figure 3-2. accumulator a (a) bit 7654321bit 0 b7 b6 b5 b4 b3 b2 b1 b0 reset: unaffected by reset figure 3-3. accumulator b (b) bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 bit 0 d15 (a7) d14 (a6) d13 (a5) d12 (a4) d11 (a3) d10 (a2) d9 (a1) d8 (a0) d7 (b7) d6 (b6) d5 (b5) d4 (b4) d3 (b3) d2 (b2) d1 (b1) d0 (b0) reset: unaffected by reset figure 3-4. accumulator d (d)
MC68HC812A4 ? rev. 5.0 advance information 64 central processor unit (cpu12) motorola central processor unit (cpu12) 3.4.3 index registers x and y index registers x and y are used for indexed addressing. indexed addressing adds the value in an index register to a constant or to the value in an accumulator to form the effective address of the operand. index registers x and y can also serve as temporary data storage locations. 3.4.4 stack pointer the stack pointer (sp) contains the last stack address used. the cpu12 supports an automatic program stack that is used to save system context during subroutine calls and interrupts. the stack pointer can also serve as a temporary data storage location or as an index register for indexed addressing. bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 bit 0 x15 x14 x13 x12 x11 x10 x9 x8 x7 x6 x5 x4 x3 x2 x1 x0 reset: unaffected by reset figure 3-5. index register x (x) bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 bit 0 y15 y14 y13 y12 y11 y10 y9 y8 y7 y6 y5 y4 y3 y2 y1 y0 reset: unaffected by reset figure 3-6. index register y (y) bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 bit 0 sp15 sp14 sp13 sp12 sp11 sp10 sp9 sp8 sp7 sp6 sp5 sp4 sp3 sp2 sp1 sp0 reset: unaffected by reset figure 3-7. stack pointer (sp)
central processor unit (cpu12) cpu registers advance information MC68HC812A4 ? rev. 5.0 motorola central processor unit (cpu12) 65 3.4.5 program counter the program counter contains the address of the next instruction to be executed. the program counter can also serve as an index register in all indexed addressing modes except autoincrement and autodecrement. 3.4.6 condition code register s ? stop disable bit setting the s bit disables the stop instruction. x ? xirq interrupt mask bit setting the x bit masks interrupt requests from the xirq pin. h ? half-carry flag the h flag is used only for bcd arithmetic operations. it is set when an aba, add, or adc instruction produces a carry from bit 3 of accumulator a. the daa instruction uses the h flag and the c flag to adjust the result to correct bcd format. bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 bit 0 sp15 sp14 sp13 sp12 sp11 sp10 sp9 sp8 sp7 sp6 sp5 sp4 sp3 sp2 sp1 sp0 reset: unaffected by reset figure 3-8. program counter (pc) bit 7654321bit 0 sxh i nzvc reset:u1u1uuuu u = unaffected figure 3-9. condition code register (ccr)
MC68HC812A4 ? rev. 5.0 advance information 66 central processor unit (cpu12) motorola central processor unit (cpu12) i ? interrupt mask bit setting the i bit disables maskable interrupt sources. n ? negative flag the n flag is set when the result of an operation is less than 0. z ? zero flag the z flag is set when the result of an operation is all 0s. v ? two ? s complement overflow flag the v flag is set when a two ? s complement overflow occurs. c ? carry/borrow flag the c flag is set when an addition or subtraction operation produces a carry or borrow. 3.5 data types the cpu12 supports four data types: 1. bit data 2. 8-bit and 16-bit signed and unsigned integers 3. 16-bit unsigned fractions 4. 16-bit addresses a byte is eight bits wide and can be accessed at any byte location. a word is composed of two consecutive bytes with the most significant byte at the lower value address. there are no special requirements for alignment of instructions or operands.
central processor unit (cpu12) addressing modes advance information MC68HC812A4 ? rev. 5.0 motorola central processor unit (cpu12) 67 3.6 addressing modes addressing modes determine how the cpu accesses memory locations to be operated upon. the cpu12 includes all of the addressing modes of the m68hc11 cpu as well as several new forms of indexed addressing. table 3-1 is a summary of the available addressing modes. table 3-1. addressing mode summary addressing mode source format abbreviation description inherent inst inh operands (if any) are in cpu registers. immediate inst # opr8i or inst # opr16i imm operand is included in instruction stream. 8- or 16-bit size implied by context direct inst opr8a dir operand is the lower 8 bits of an address in the range $0000 ? $00ff. extended inst opr16a ext operand is a 16-bit address relative inst rel8 or inst rel16 rel an 8-bit or 16-bit relative offset from the current pc is supplied in the instruction. indexed (5-bit offset) inst oprx5 , xysp idx 5-bit signed constant offset from x, y, sp, or pc indexed (auto pre-decrement) inst oprx3 , ? xys idx auto pre-decrement x, y, or sp by 1 ~ 8 indexed (auto pre-increment) inst oprx3 , +xys idx auto pre-increment x, y, or sp by 1 ~ 8 indexed (auto post-decrement) inst oprx3 , xys ? idx auto post-decrement x, y, or sp by 1 ~ 8 indexed (auto post-increment) inst oprx3 , xys+ idx auto post-increment x, y, or sp by 1 ~ 8 indexed (accumulator offset) inst abd , xysp idx indexed with 8-bit (a or b) or 16-bit (d) accumulator offset from x, y, sp, or pc indexed (9-bit offset) inst oprx9 , xysp idx1 9-bit signed constant offset from x, y, sp, or pc (lower 8-bits of offset in one extension byte) indexed (16-bit offset) inst oprx16 , xysp idx2 16-bit constant offset from x, y, sp, or pc (16-bit offset in two extension bytes) indexed-indirect (16-bit offset) inst [ oprx16 , xysp ][idx2] pointer to operand is found at... 16-bit constant offset from x, y, sp, or pc (16-bit offset in two extension bytes) indexed-indirect (d accumulator offset) inst [d, xysp ][d,idx] pointer to operand is found at... x, y, sp, or pc plus the value in d
MC68HC812A4 ? rev. 5.0 advance information 68 central processor unit (cpu12) motorola central processor unit (cpu12) 3.7 indexed addressing modes the cpu12 indexed modes reduce execution time and eliminate code size penalties for using the y index register. cpu12 indexed addressing uses a postbyte plus zero, one, or two extension bytes after the instruction opcode. the postbyte and extensions do these tasks:  specify which index register is used  determine whether a value in an accumulator is used as an offset  enable automatic pre- or post-increment or decrement  specify use of 5-bit, 9-bit, or 16-bit signed offsets table 3-2. summary of indexed operations postbyte code (xb) source code syntax comments rr: 00 = x, 01 = y, 10 = sp, 11 = pc rr0nnnnn ,r n,r ?n,r 5-bit constant offset n = ? 16 to +15 r can specify x, y, sp, or pc 111rr0zs n,r ? n,r constant offset (9- or 16-bit signed) z:0 = 9-bit with sign in lsb of postbyte(s) 1 = 16-bit if z = s = 1, 16-bit offset indexed-indirect (see below) rr can specify x, y, sp, or pc 111rr011 [n,r] 16-bit offset indexed-indirect rr can specify x, y, sp, or pc rr1pnnnn n, ? r n,+r n,r ? n,r+ auto pre-decrement/increment or auto post-decrement/increment ; p = pre-(0) or post-(1), n = ? 8 to ? 1, +1 to +8 rr can specify x, y, or sp (pc not a valid choice) 111rr1aa a,r b,r d,r accumulator offset (unsigned 8-bit or 16-bit) aa:00 = a 01 = b 10 = d (16-bit) 11 = see accumulator d offset indexed-indirect rr can specify x, y, sp, or pc 111rr111 [d,r] accumulator d offset indexed-indirect rr can specify x, y, sp, or pc
central processor unit (cpu12) opcodes and operands advance information MC68HC812A4 ? rev. 5.0 motorola central processor unit (cpu12) 69 3.8 opcodes and operands the cpu12 uses 8-bit opcodes. each opcode identifies a particular instruction and associated addressing mode to the cpu. several opcodes are required to provide each instruction with a range of addressing capabilities. only 256 opcodes would be available if the range of values were restricted to the number that can be represented by 8-bit binary numbers. to expand the number of opcodes, a second page is added to the opcode map. opcodes on the second page are preceded by an additional byte with the value $18. to provide additional addressing flexibility, opcodes can also be followed by a postbyte or extension bytes. postbytes implement certain forms of indexed addressing, transfers, exchanges, and loop primitives. extension bytes contain additional program information such as addresses, offsets, and immediate data.
MC68HC812A4 ? rev. 5.0 advance information 70 central processor unit (cpu12) motorola central processor unit (cpu12)
advance information MC68HC812A4 ? rev. 5.0 motorola resets and interrupts 71 advance information ? MC68HC812A4 section 4. resets and interrupts 4.1 contents 4.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72 4.3 exception priority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 4.4 maskable interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .73 4.5 interrupt registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75 4.5.1 interrupt control register . . . . . . . . . . . . . . . . . . . . . . . . .75 4.5.2 highest priority i interrupt register . . . . . . . . . . . . . . . . . .76 4.6 resets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 4.6.1 power-on reset. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .76 4.6.2 external reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .77 4.6.3 cop reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .77 4.6.4 clock monitor reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 4.7 effects of reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 4.7.1 operating mode and memory map. . . . . . . . . . . . . . . . . . . .78 4.7.2 clock and watchdog control logic . . . . . . . . . . . . . . . . . . .78 4.7.3 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .78 4.7.4 parallel i/o . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .78 4.7.5 central processor unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79 4.7.6 memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79 4.7.7 other resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79 4.8 interrupt recognition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79
MC68HC812A4 ? rev. 5.0 advance information 72 resets and interrupts motorola resets and interrupts 4.2 introduction resets and interrupts are exceptions. each exception has a 16-bit vector that points to the memory location of the associated exception-handling routine. vectors are stored in the upper 128 bytes of the standard 64-kbyte address map. the six highest vector addresses are used for resets and non-maskable interrupt sources. the remainder of the vectors are used for maskable interrupts, and all must be initialized to point to the address of the appropriate service routine. 4.3 exception priority a hardware priority hierarchy determines which reset or interrupt is serviced first when simultaneous requests are made. six sources are not maskable. the remaining sources are maskable and any one of them can be given priority over other maskable interrupts. the priorities of the non-maskable sources are: 1. por (power-on reset) or reset pin 2. clock monitor reset 3. cop (computer operating properly) watchdog reset 4. unimplemented instruction trap 5. software interrupt instruction (swi) 6. xirq signal (if x bit in ccr = 0)
resets and interrupts maskable interrupts advance information MC68HC812A4 ? rev. 5.0 motorola resets and interrupts 73 4.4 maskable interrupts maskable interrupt sources include on-chip peripheral systems and external interrupt service requests. interrupts from these sources are recognized when the global interrupt mask bit (i) in the ccr is cleared. the default state of the i bit out of reset is 1, but it can be written at any time. interrupt sources are prioritized by default but any one maskable interrupt source may be assigned the highest priority by means of the hprio register. the relative priorities of the other sources remain the same. an interrupt that is assigned highest priority is still subject to global masking by the i bit in the ccr or by any associated local bits. interrupt vectors are not affected by priority assignment. hprio can only be written while the i bit is set (interrupts inhibited). table 4-1 lists interrupt sources and vectors in default order of priority. table 4-1. interrupt vector map vector address exception source flag local enable ccr mask hprio value to elevate $fffe, $ffff power-on reset ? none none ? $fffc, $fffd cop clock monitor reset ? cme, fcme none ? $fffa, $fffb cop reset ? cop rate selected none ? $fff8, $fff9 unimplemented instruction trap ? none none ? $fff6, $fff7 swi instruction ? none none ? $fff4, $fff5 xirq pin ? none x bit ? $fff2, $fff3 irq pin or key wakeup d ? irqen, kwied[7 ? 0] i bit $f2 $fff0, $fff1 real-time interrupt rtif rtie i bit $f0 $ffee, $ffef timer channel 0 c0f c0i i bit $ee $ffec, $ffed timer channel 1 c1f c1i i bit $ec $ffea, $ffeb timer channel 2 c2f c2i i bit $ea $ffe8, $ffe9 timer channel 3 c3f c3i i bit $e8 $ffe6, $ffe7 timer channel 4 c4f c4i i bit $e6
MC68HC812A4 ? rev. 5.0 advance information 74 resets and interrupts motorola resets and interrupts $ffe4, $ffe5 timer channel 5 c5f c5i i bit $e4 $ffe2, $ffe3 timer channel 6 c6f c6i i bit $e2 $ffe0, $ffe1 timer channel 7 c7f c7i i bit $e0 $ffde, $ffdf timer overflow tof toi i bit $de $ffdc, $ffdd pulse accumulator overflow paovf paovi i bit $dc $ffda, $ffdb pulse accumulator input edge paif pai i bit $da $ffd8, $ffd9 spi serial transfer complete mode fault spif modf spi0e i bit $d8 $ffd6, $ffd7 sci0 transmit data register empty sci0 transmission complete sci0 receive data register full sci0 receiver overrun sci0 receiver idle tdre tc rdrf or idle tie tcie rie rie ilie i bit $d6 $ffd4, $ffd5 sci1 transmit data register empty sci1 transmission complete sci1 receive data register full sci1 receiver overrun sci1 receiver idle tdre tc rdrf or idle tie tcie rie rie ilie i bit $d4 $ffd2, $ffd3 atd ascif ascie i bit $d2 $ffd0, $ffd1 key wakeup j (stop wakeup) ? kwiej[7 ? 0] i bit $d0 $ffce, $ffcf key wakeup h (stop wakeup) ? kwieh[7 ? 0] i bit $ce $ff80 ? $ffcd reserved ?? i bit $80 ? $cc table 4-1. interrupt vector map (continued) vector address exception source flag local enable ccr mask hprio value to elevate
resets and interrupts interrupt registers advance information MC68HC812A4 ? rev. 5.0 motorola resets and interrupts 75 4.5 interrupt registers this section describes the interrupt registers. 4.5.1 interrupt control register read: anytime write: varies from bit to bit irqe ? irq edge-sensitive-only bit irqe can be written once in normal modes. in special modes, irqe can be written anytime, but the first write is ignored. 1 = irq responds only to falling edges. 0 = irq pin responds to low levels. irqen ? irq enable bit irqen can be written anytime in all modes. the irq pin has an internal pullup. 1 = irq pin and key wakeup d connected to interrupt logic 0 = irq pin and key wakeup d disconnected from interrupt logic dly ? oscillator startup delay on exit from stop mode bit dly can be written once in normal modes. in special modes, dly can be written anytime. the delay time of about 4096 cycles is based on the m-clock rate chosen. 1 = stabilization delay on exit from stop mode 0 = no stabilization delay on exit from stop mode address: $001e bit 7654321bit 0 read: irqe irqen dly 00000 write: reset:01100000 = unimplemented figure 4-1. interrupt control register (intcr)
MC68HC812A4 ? rev. 5.0 advance information 76 resets and interrupts motorola resets and interrupts 4.5.2 highest priority i interrupt register read: anytime write: only if i mask in ccr = 1 (interrupts inhibited) to give a maskable interrupt source highest priority, write the low byte of the vector address to the hprio register. for example, writing $f0 to hprio assigns highest maskable interrupt priority to the real-time interrupt timer ($fff0). if an unimplemented vector address or a non-i-masked vector address (a value higher than $f2) is written, then irq is the default highest priority interrupt. 4.6 resets there are five possible sources of reset. power-on reset (por), external reset on the reset pin, and reset from the alternate reset pin, arst, share the normal reset vector. the computer operating properly (cop) reset and the clock monitor reset each has a vector. entry into reset is asynchronous and does not require a clock but the mcu cannot sequence out of reset without a system clock. 4.6.1 power-on reset a positive transition on v dd causes a power-on reset (por). an external voltage level detector, or other external reset circuits, are the usual source of reset in a system. the por circuit only initializes internal circuitry during cold starts and cannot be used to force a reset as system voltage drops. address: $001f bit 7654321bit 0 read: 1 1 psel5 psel4 psel3 psel2 psel1 0 write: reset:11110010 = unimplemented figure 4-2. highest priority i interrupt register (hprio)
resets and interrupts effects of reset advance information MC68HC812A4 ? rev. 5.0 motorola resets and interrupts 77 4.6.2 external reset the cpu distinguishes between internal and external reset conditions by sensing whether the reset pin rises to a logic 1 in less than eight e-clock cycles after an internal device releases reset. when a reset condition is sensed, the reset pin is driven low by an internal device for about 16 e-clock cycles, then released. eight e-clock cycles later, it is sampled. if the pin is still held low, the cpu assumes that an external reset has occurred. if the pin is high, it indicates that the reset was initiated internally by either the cop system or the clock monitor. to prevent a cop or clock monitor reset from being detected during an external reset, hold the reset pin low for at least 32 cycles. an external rc power-up delay circuit on the reset pin is not recommended since circuit charge time can cause the mcu to misinterpret the type of reset that has occurred. 4.6.3 cop reset the mcu includes a computer operating properly (cop) system to help protect against software failures. when cop is enabled, software must write $55 and $aa (in this order) to the coprst register to keep a watchdog timer from timing out. other instructions may be executed between these writes. a write of any value other than $55 or $aa or software failing to execute the sequence properly causes a cop reset to occur. 4.6.4 clock monitor reset if clock frequency falls below a predetermined limit when the clock monitor is enabled, a reset occurs. 4.7 effects of reset when a reset occurs, mcu registers and control bits are changed to known startup states, as follows.
MC68HC812A4 ? rev. 5.0 advance information 78 resets and interrupts motorola resets and interrupts 4.7.1 operating mode and memory map the states of the bgnd, moda, and modb pins during reset determine the operating mode and default memory mapping. the smodn, moda, and modb bits in the mode register reflect the status of the mode-select inputs at the rising edge of reset. operating mode and default maps can subsequently be changed according to strictly defined rules. 4.7.2 clock and watchdog control logic reset enables the cop watchdog with the cr2 ? cr0 bits set for the longest timeout period. the clock monitor is disabled. the rtif flag is cleared and automatic hardware interrupts are masked. the rate control bits are cleared, and must be initialized before the rti system is used. the dly control bit is set to specify an oscillator startup delay upon recovery from stop mode. 4.7.3 interrupts reset initializes the hprio register with the value $f2, causing the irq pin to have the highest i bit interrupt priority. the irq pin is configured for level-sensitive operation (for wired-or systems). however, the i and x bits in the ccr are set, masking irq and xirq interrupt requests. 4.7.4 parallel i/o if the mcu comes out of reset in an expanded mode, port a and port b are the address bus. port c and port d are the data bus. in narrow mode, port c alone is the data bus. port e pins are normally used to control the external bus. the pear register affects port e pin operation. if the mcu comes out of reset in a single-chip mode, all ports are configured as general-purpose, high-impedance inputs except in normal narrow expanded mode (nne). in nne, pe3 is configured as an output driven high. in expanded modes, pf5 is an active chip-select.
resets and interrupts interrupt recognition advance information MC68HC812A4 ? rev. 5.0 motorola resets and interrupts 79 4.7.5 central processor unit after reset, the cpu fetches a vector from the appropriate address and begins executing instructions. the stack pointer and other cpu registers are indeterminate immediately after reset. the ccr x and i interrupt mask bits are set to mask any interrupt requests. the s bit is also set to inhibit the stop instruction. 4.7.6 memory after reset, the internal register block is located at $0000 ? $01ff and ram is at $0800 ? $0bff. eeprom is located at $1000 ? $1fff in expanded modes and at $f000 ? $ffff in single-chip modes. 4.7.7 other resources the timer, serial communications interface (sci), serial peripheral interface (spi), and analog-to-digital converter (atd) are off after reset. 4.8 interrupt recognition once enabled, an interrupt request can be recognized at any time after the i bit in the ccr is cleared. when an interrupt request is recognized, the cpu responds at the completion of the instruction being executed. interrupt latency varies according to the number of cycles required to complete the instruction. some of the longer instructions can be interrupted and resume normally after servicing the interrupt. when the cpu begins to service an interrupt request, it:  clears the instruction queue  calculates the return address  stacks the return address and the contents of the cpu registers as shown in table 4-2
MC68HC812A4 ? rev. 5.0 advance information 80 resets and interrupts motorola resets and interrupts after stacking the ccr, the cpu:  sets the i bit to prevent other interrupts from disrupting the interrupt service routine  sets the x bit if an xirq interrupt request is pending  fetches the interrupt vector for the highest-priority request that was pending at the beginning of the interrupt sequence  begins execution of the interrupt service routine at the location pointed to by the vector if no other interrupt request is pending at the end of the interrupt service routine, an rti instruction recovers the stacked values. program execution resumes program at the return address. if another interrupt request is pending at the end of an interrupt service routine, the rti instruction recovers the stacked values. however, the cpu then:  adjusts the stack pointer to point again at the stacked ccr location, sp ? 9  fetches the vector of the pending interrupt  begins execution of the interrupt service routine at the location pointed to by the vector table 4-2. stacking order on entry to interrupts memory location stacked values sp ? 2 rtn h : rtn l sp ? 4 y h : y l sp ? 6 x h : x l sp ? 8b : a sp ? 9 ccr
advance information MC68HC812A4 ? rev. 5.0 motorola operating modes and resource mapping 81 advance information ? MC68HC812A4 section 5. operating modes and resource mapping 5.1 contents 5.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81 5.3 operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82 5.3.1 normal operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . .83 5.3.1.1 normal expanded wide mode . . . . . . . . . . . . . . . . . . . . .83 5.3.1.2 normal expanded narrow mode . . . . . . . . . . . . . . . . . . .83 5.3.1.3 normal single-chip mode . . . . . . . . . . . . . . . . . . . . . . . .83 5.3.2 special operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . .84 5.3.2.1 special expanded wide mode . . . . . . . . . . . . . . . . . . . . .84 5.3.2.2 special expanded narrow mode . . . . . . . . . . . . . . . . . . .84 5.3.2.3 special single-chip mode . . . . . . . . . . . . . . . . . . . . . . . .84 5.3.2.4 special peripheral mode . . . . . . . . . . . . . . . . . . . . . . . . .84 5.3.3 background debug mode. . . . . . . . . . . . . . . . . . . . . . . . . . .85 5.4 internal resource mapping. . . . . . . . . . . . . . . . . . . . . . . . . . . .85 5.5 mode and resource mapping registers . . . . . . . . . . . . . . . . .87 5.5.1 mode register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .87 5.5.2 register initialization register . . . . . . . . . . . . . . . . . . . . . . .89 5.5.3 ram initialization register . . . . . . . . . . . . . . . . . . . . . . . . . . 90 5.5.4 eeprom initialization register . . . . . . . . . . . . . . . . . . . . . . 90 5.5.5 miscellaneous mapping control register . . . . . . . . . . . . . . .91 5.6 memory map. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93 5.2 introduction the mcu can operate in eight different modes. each mode has a different default memory map and external bus configuration. after reset, most system resources can be mapped to other addresses by writing to the appropriate control registers.
MC68HC812A4 ? rev. 5.0 advance information 82 operating modes and resource mapping motorola operating modes and resource mapping 5.3 operating modes the states of the bkgd, modb, and moda pins during reset determine the operating mode after reset. the smodn, modb, and moda bits in the mode register show the current operating mode and provide limited mode switching during operation. the states of the bkgd, modb, and moda pins are latched into these bits on the rising edge of the reset signal. the two basic types of operating modes are:  normal modes ? some registers and bits are protected against accidental changes.  special modes ? protected control registers and bits are allowed greater access for special purposes such as testing and emulation. a system development and debug feature, background debug mode (bdm), is available in all modes. in special single-chip mode, bdm is active immediately after reset. table 5-1. mode selection bkgdmodbmoda mode port a port b port c port d 0 0 0 special single-chip g.p. (1) i/o 1. g.p. = general purpose g.p. i/o g.p. i/o 0 0 1 special expanded narrow addr data g.p. i/o 0 1 0 special peripheral addr data data 0 1 1 special expanded wide addr data data 1 0 0 normal single chip g.p. i/o g.p. i/o g.p. i/o 1 0 1 normal expanded narrow addr data g.p. i/o 110 reserved (forced to peripheral) ??? 1 1 1 normal expanded wide addr data data
operating modes and resource mapping operating modes advance information MC68HC812A4 ? rev. 5.0 motorola operating modes and resource mapping 83 5.3.1 normal operating modes these modes provide three operating configurations. background debugging is available in all three modes, but must first be enabled for some operations by means of a bdm command. bdm can then be made active by another bdm command. 5.3.1.1 normal expanded wide mode the 16-bit external address bus uses port a for the high byte and port b for the low byte. the 16-bit external data bus uses port c for the high byte and port d for the low byte. 5.3.1.2 normal expanded narrow mode the 16-bit external address bus uses port a for the high byte and port b for the low byte. the 8-bit external data bus uses port c. in this mode, 16-bit data is presented high byte first, followed by the low byte. the address is automatically incremented on the second cycle. 5.3.1.3 normal single-chip mode there are no external buses in normal single-chip mode. the mcu operates as a stand-alone device and all program and data resources are on-chip. port pins can be used for general-purpose i/o (input/output).
MC68HC812A4 ? rev. 5.0 advance information 84 operating modes and resource mapping motorola operating modes and resource mapping 5.3.2 special operating modes special operating modes are commonly used in factory testing and system development. 5.3.2.1 special expanded wide mode this mode is for emulation of normal expanded wide mode and emulation of normal single-chip mode with a 16-bit bus. the bus-control pins of port e are all configured for their bus-control output functions rather than general-purpose i/o. 5.3.2.2 special expanded narrow mode this mode is for emulation of normal expanded narrow mode. external 16-bit data is handled as two back-to-back bus cycles, one for the high byte followed by one for the low byte. internal operations continue to use full 16-bit data paths. for development purposes, port d can be made available for visibility of 16-bit internal accesses by setting the emd and ivis control bits. 5.3.2.3 special single-chip mode this mode can be used to force the mcu to active bdm mode to allow system debug through the bkgd pin. there are no external address and data buses in this mode. the mcu operates as a stand-alone device and all program and data space are on-chip. external port pins can be used for general-purpose i/o. 5.3.2.4 special peripheral mode the cpu is not active in this mode. an external master can control on-chip peripherals for testing purposes. it is not possible to change to or from this mode without going through reset. background debugging should not be used while the mcu is in special peripheral mode as internal bus conflicts between bdm and the external master can cause improper operation of both modes.
operating modes and resource mapping internal resource mapping advance information MC68HC812A4 ? rev. 5.0 motorola operating modes and resource mapping 85 5.3.3 background debug mode background debug mode (bdm) is an auxiliary operating mode that is used for system development. bdm is implemented in on-chip hardware and provides a full set of debug operations. some bdm commands can be executed while the cpu is operating normally. other bdm commands are firmware based and require the bdm firmware to be enabled and active for execution. in special single-chip mode, bdm is enabled and active immediately out of reset. bdm is available in all other operating modes, but must be enabled before it can be activated. bdm should not be used in special peripheral mode because of potential bus conflicts. once enabled, background mode can be made active by a serial command sent via the bkgd pin or execution of a cpu12 bgnd instruction. while background mode is active, the cpu can interpret special debugging commands, and read and write cpu registers, peripheral registers, and locations in memory. while bdm is active, the cpu executes code located in a small on-chip rom mapped to addresses $ff20 to $ffff, and bdm control registers are accessible at addresses $ff00 to $ff06. the bdm rom replaces the regular system vectors while bdm is active. while bdm is active, the user memory from $ff00 to $ffff is not in the map except through serial bdm commands. 5.4 internal resource mapping the internal register block, ram, and eeprom have default locations within the 64-kbyte standard address space but may be reassigned to other locations during program execution by setting bits in mapping registers initrg, initrm, and initee. during normal operating modes, these registers can be written once. it is advisable to explicitly establish these resource locations during the initialization phase of program execution, even if default values are chosen, to protect the registers from inadvertent modification later.
MC68HC812A4 ? rev. 5.0 advance information 86 operating modes and resource mapping motorola operating modes and resource mapping writes to the mapping registers go into effect between the cycle that follows the write and the cycle after that. to assure that there are no unintended operations, a write to one of these registers should be followed with a nop (no operation) instruction. if conflicts occur when mapping resources, the register block takes precedence over the other resources; ram or eeprom addresses occupied by the register block are not available for storage. when active, bdm rom takes precedence over other resources although a conflict between bdm rom and register space is not possible. table 5-2 shows resource mapping precedence. all address space not used by internal resources is external memory by default. the memory expansion module manages three memory overlay windows: 1. program 2. data 3. one extra page overlay the sizes and locations of the program and data overlay windows are fixed. one of two locations can be selected for the extra page (epage). table 5-2. mapping precedence precedence resource 1 bdm rom (if active) 2 register space 3ram 4 eeprom 5 external memory
operating modes and resource mapping mode and resource mapping registers advance information MC68HC812A4 ? rev. 5.0 motorola operating modes and resource mapping 87 5.5 mode and resource mapping registers this section describes the mode and resource mapping registers. 5.5.1 mode register mode controls the mcu operating mode and various configuration options. this register is not in the map in peripheral mode. read: anytime write: varies from bit to bit smodn, modb, and moda ? mode select special, b, and a bits these bits show the current operating mode and reflect the status of the bkgd, modb, and moda input pins at the rising edge of reset. smodn can be written only if smodn = 0 (in special modes) but the first write is ignored. modb and moda may be written once if smodn = 1; anytime if smodn = 0, except that special peripheral and reserved modes cannot be selected. address: $000b bit 7654321bit 0 read: smodn modb moda estr ivis 0 emd eme write: reset states special single-chip: 0 0 0 1 1 0 1 1 special expanded narrow: 0 0 1 1 1 0 1 1 peripheral: 0 1 0 1 1 0 1 1 special expanded wide: 0 1 1 1 1 0 1 1 normal single-chip:10010000 normal expanded narrow: 1 0 1 1 0 0 0 0 normal expanded wide: 1 1 1 1 0 0 0 0 figure 5-1. mode register (mode)
MC68HC812A4 ? rev. 5.0 advance information 88 operating modes and resource mapping motorola operating modes and resource mapping estr ? e-clock stretch enable bit estr determines if the e-clock behaves as a simple free-running clock or as a bus control signal that is active only for external bus cycles. 1 = e stretches high during external access cycles and low during non-visible internal accesses. 0 = e never stretches (always free running). normal modes: write once special modes: write anytime ivis ? internal visibility bit ivis determines whether internal addr, data, r/w , and lstrb signals can be seen on the external bus during accesses to internal locations. if this bit is set in special narrow mode and emd = 1 when an internal access occurs, the data appears wide on port c and port d. this allows for emulation. visibility is not available when the part is operating in a single-chip mode. 1 = internal bus operations are visible on external bus. 0 = internal bus operations are not visible on external bus. normal modes: write once special modes: write anytime except the first time emd ? emulate port d bit this bit only has meaning in special expanded narrow mode. in expanded wide modes and special peripheral mode, portd, ddrd, kwied, and kwifd are removed from the memory map regardless of the state of this bit. in single-chip modes and normal expanded narrow mode, portd, ddrd, kwied, and kwifd are in the memory map regardless of the state of this bit. 1 = if in special expanded narrow mode, portd, ddrd, kwied, and kwifd are removed from the memory map. removing the registers from the map allows the user to emulate the function of these registers externally. 0 = portd, ddrd, kwied, and kwifd are in the memory map. normal modes: write once special modes: write anytime except the first time
operating modes and resource mapping mode and resource mapping registers advance information MC68HC812A4 ? rev. 5.0 motorola operating modes and resource mapping 89 eme ? emulate port e bit in single-chip mode, porte and ddre are always in the map regardless of the state of this bit. 1 = if in an expanded mode, porte and ddre are removed from the internal memory map. removing the registers from the map allows the user to emulate the function of these registers externally. 0 = porte and ddre in the memory map normal modes: write once special modes: write anytime except the first time 5.5.2 register initialization register after reset, the 512-byte register block resides at location $0000 but can be reassigned to any 2-kbyte boundary within the standard 64-kbyte address space. mapping of internal registers is controlled by five bits in the initrg register. the register block occupies the first 512 bytes of the 2-kbyte block. read: anytime write: once in normal modes; anytime in special modes reg15 ? reg11 ? register position bits these bits specify the upper five bits of the 16-bit register address. address: $0011 bit 7654321bit 0 read: reg15 reg14 reg13 reg12 reg11 0 0 0 write: reset:00000000 figure 5-2. register initialization register (initrg)
MC68HC812A4 ? rev. 5.0 advance information 90 operating modes and resource mapping motorola operating modes and resource mapping 5.5.3 ram initialization register after reset, addresses of the 1-kbyte ram array begin at location $0800 but can be assigned to any 2-kbyte boundary within the standard 64-kbyte address space. mapping of internal ram is controlled by five bits in the initrm register. the ram array occupies the last 1 kbyte of the 2-kbyte block. read: anytime write: once in normal modes; anytime in special modes ram15 ? ram11 ? ram position bits these bits specify the upper five bits of the 16-bit ram address. 5.5.4 eeprom initialization register the mcu has 4 kbytes of eeprom which is activated by the eeon bit in the initee register. mapping of internal eeprom is controlled by four bits in the initee register. after reset, eeprom address space begins at location $1000 but can be mapped to any 4-kbyte boundary within the standard 64-kbyte address space. address: $0010 bit 7654321bit 0 read: ram15 ram14 ram13 ram12 ram11 0 0 0 write: reset:00001000 figure 5-3. ram initialization register (initrm)
operating modes and resource mapping mode and resource mapping registers advance information MC68HC812A4 ? rev. 5.0 motorola operating modes and resource mapping 91 read: anytime write: varies from bit to bit ee15 ? ee12 ? eeprom position bits these bits specify the upper four bits of the 16-bit eeprom address. normal modes: write once special modes: write anytime eeon ? eeprom on bit eeon enables the on-chip eeprom. eeon is forced to 1 in single-chip modes. write anytime 1 = eeprom at address selected by ee15 ? ee12 0 = eeprom removed from memory map 5.5.5 miscellaneous mapping control register additional mapping controls are available that can be used in conjunction with memory expansion and chip selects. to use memory expansion, the part must be operated in one of the expanded modes. sections of the standard 64-kbyte memory map have memory expansion windows which allow more than 64 kbytes to be addressed externally. memory expansion consists of three memory expansion windows and six address lines in addition to the existing standard 16 address lines. the memory expansion function reuses as address: $0012 bit 7654321bit 0 read: ee15 ee14 ee13 ee12 0 0 0 eeon write: reset: expanded and peripheral: 0 0 010001 single-chip:11110001 figure 5-4. eeprom initialization register (initee)
MC68HC812A4 ? rev. 5.0 advance information 92 operating modes and resource mapping motorola operating modes and resource mapping many as six of the standard 16 address lines. usage of chip selects identifies the source of the internal address. all of the memory expansion windows have a fixed size and two of them have a fixed address location. the third has two selectable address locations. read: anytime write: once in normal modes; anytime in special modes ewdir ? extra window positioned in direct space bit this bit is only valid in expanded modes. if the ewen bit in the windef register is cleared, then this bit has no meaning or effect. 1 = if ewen is set, then a 1 in this bit places the epage at $0000 ? $03ff. 0 = if ewen is set, then a 0 in this bit places the epage at $0400 ? $07ff. ndrc ? narrow data bus for register chip-select space bit this function requires at least one of the chip selects cs3 ? cs0 to be enabled. it effects the external 512-byte memory space. 1 = makes the register-following chip-selects (2, 1, 0, and sometimes 3) active space (512-byte block) act the same as an 8-bit only external data bus. data only goes through port c externally. this allows 8-bit and 16-bit external memory devices to be mixed in a system. 0 = makes the register-following chip-select active space act as a full 16-bit data bus. in the narrow (8-bit) mode, ndrc has no effect. address: $0013 bit 7654321bit 0 read: ewdirndrc000000 write: reset:00000000 figure 5-5. miscellaneous mapping control register (misc)
operating modes and resource mapping memory map advance information MC68HC812A4 ? rev. 5.0 motorola operating modes and resource mapping 93 5.6 memory map figure 5-6 illustrates the memory map for each mode of operation immediately after reset. figure 5-6. memory map $1fff registers mappable to any 2-k space $01ff ram mappable to any 2-k space single-chip normal single-chip special ext ext $0bff $ffff $f000 eeprom mappable to any 4-k space $1000 ext vectors vectors bdm if active eeprom single-chip modes $ffff $0000 $0800 $ffff $ff00 $ff00 $f000 $1000 $0000 $0800 $2000 $ffc0 expanded vectors
MC68HC812A4 ? rev. 5.0 advance information 94 operating modes and resource mapping motorola operating modes and resource mapping
advance information MC68HC812A4 ? rev. 5.0 motorola bus control and input/output (i/o) 95 advance information ? MC68HC812A4 section 6. bus control and input/output (i/o) 6.1 contents 6.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95 6.3 detecting access type from external signals . . . . . . . . . . . . .96 6.4 registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .97 6.4.1 port a data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 6.4.2 port a data direction register . . . . . . . . . . . . . . . . . . . . . . . 98 6.4.3 port b data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 6.4.4 port b data direction register . . . . . . . . . . . . . . . . . . . . . . . 99 6.4.5 port c data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100 6.4.6 port c data direction register . . . . . . . . . . . . . . . . . . . . . .101 6.4.7 port d data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102 6.4.8 port d data direction register . . . . . . . . . . . . . . . . . . . . . .103 6.4.9 port e data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . .104 6.4.10 port e data direction register . . . . . . . . . . . . . . . . . . . . . .105 6.4.11 port e assignment register . . . . . . . . . . . . . . . . . . . . . . . .106 6.4.12 pullup control register . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 6.4.13 reduced drive register . . . . . . . . . . . . . . . . . . . . . . . . . . .110 6.2 introduction internally the mcu has full 16-bit data paths, but depending upon the operating mode and control registers, the external bus may be 8 or 16 bits. there are cases where 8-bit and 16-bit accesses can appear on adjacent cycles using the lstrb signal to indicate 8-bit or 16-bit data.
MC68HC812A4 ? rev. 5.0 advance information 96 bus control and input/output (i/o) motorola bus control and input/output (i/o) 6.3 detecting access type from external signals the external signals lstrb , r/w , and a0 can be used to determine the type of bus access that is taking place. accesses to the internal ram module are the only type of access that produce lstrb = a0 = 1, because the internal ram is specifically designed to allow misaligned 16-bit accesses in a single cycle. in these cases, the data for the address that was accessed is on the low half of the data bus and the data for address +1 is on the high half of the data bus. table 6-1. access type versus bus control pins lstrb a0 r/w type of access 1 0 1 8-bit read of an even address 0 1 1 8-bit read of an odd address 1 0 0 8-bit write of an even address 0 1 0 8-bit write of an odd address 0 0 1 16-bit read of an even address 111 16-bit read of an odd address (low/high data swapped) 0 0 0 16-bit write to an even address 110 16-bit write to an even address (low/high data swapped)
bus control and input/output (i/o) registers advance information MC68HC812A4 ? rev. 5.0 motorola bus control and input/output (i/o) 97 6.4 registers not all registers are visible in the memory map under certain conditions. in special peripheral mode, the first 16 registers associated with bus expansion are removed from the memory map. in expanded modes, some or all of port a, port b, port c, port d, and port e are used for expansion buses and control signals. to allow emulation of the single-chip functions of these ports, some of these registers must be rebuilt in an external port replacement unit. in any expanded mode, port a, port b, and port c are used for address and data lines so registers for these ports, as well as the data direction registers for these ports, are removed from the on-chip memory map and become external accesses. port d and its associated data direction register may be removed from the on-chip map when port d is needed for 16-bit data transfers. if the mcu is in an expanded wide mode, port c and port d are used for 16-bit data and the associated port and data direction registers become external accesses. when the mcu is in expanded narrow mode, the external data bus is normally 8 bits. to allow full-speed operation while allowing visibility of internal 16-bit accesses, a 16-bit-wide data path is required. the emulate port d (emd) control bit in the mode register may be set to allow such 16-bit transfers. in this case of narrow special expanded mode and the emd bit set, port d and data direction d registers are removed from the on-chip memory map and become external accesses so port d may be rebuilt externally. in any expanded mode, port e pins may be needed for bus control (for instance, eclk and r/w ). to regain the single-chip functions of port e, the emulate port e (eme) control bit in the mode register may be set. in this special case of expanded mode and eme set, porte and ddre registers are removed from the on-chip memory map and become external accesses so port e may be rebuilt externally.
MC68HC812A4 ? rev. 5.0 advance information 98 bus control and input/output (i/o) motorola bus control and input/output (i/o) 6.4.1 port a data register read: anytime, if register is in the map write: anytime, if register is in the map bits pa7 ? pa0 are associated with addresses addr15 ? addr8 respectively. when this port is not used for external addresses such as in single-chip mode, these pins can be used as general-purpose i/o. ddra determines the primary direction of each pin. this register is not in the on-chip map in expanded and peripheral modes. 6.4.2 port a data direction register read: anytime, if register is in the map write: anytime, if register is in the map this register determines the primary direction for each port a pin when functioning as a general-purpose i/o port. ddra is not in the on-chip map in expanded and peripheral modes. 1 = associated pin is an output. 0 = associated pin is a high-impedance input. address: $0000 bit 7654321bit 0 read: pa7 pa6 pa5 pa4 pa3 pa2 pa1 pa0 write: reset:00000000 expanded and peripheral: addr15 addr14 addr13 addr12 addr11 addr10 addr9 addr8 figure 6-1. port a data register (porta) address: $0002 bit 7654321bit 0 read: ddra7 ddra6 ddra5 ddra4 ddra3 ddra2 ddra1 ddra0 write: reset:00000000 figure 6-2. port a data direction register (ddra)
bus control and input/output (i/o) registers advance information MC68HC812A4 ? rev. 5.0 motorola bus control and input/output (i/o) 99 6.4.3 port b data register read: anytime, if register is in the map write: anytime, if register is in the map bits pb7 ? pb0 correspond to address lines addr7 ? addr0. when this port is not used for external addresses such as in single-chip mode, these pins can be used as general-purpose i/o. ddrb determines the primary direction of each pin. this register is not in the on-chip map in expanded and peripheral modes. 6.4.4 port b data direction register read: anytime, if register is in the map write: anytime, if register is in the map this register determines the primary direction for each port b pin when functioning as a general-purpose i/o port. ddrb is not in the on-chip map in expanded and peripheral modes. 1 = associated pin is an output. 0 = associated pin is a high-impedance input. address: $0001 bit 7654321bit 0 read: pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 write: reset:00000000 expanded and peripheral: addr7 addr6 addr5 addr4 addr3 addr2 addr1 addr0 figure 6-3. port b data register (portb) address: $0003 bit 7654321bit 0 read: ddrb7 ddrb6 ddrb5 ddrb4 ddrb3 ddrb2 ddrb1 ddrb0 write: reset:00000000 figure 6-4. port b data direction register (ddrb)
MC68HC812A4 ? rev. 5.0 advance information 100 bus control and input/output (i/o) motorola bus control and input/output (i/o) 6.4.5 port c data register read: anytime, if register is in the map write: anytime, if register is in the map bits pc7 ? pc0 correspond to data lines data15 ? data8. when this port is not used for external data such as in single-chip mode, these pins can be used as general-purpose i/o. ddrc determines the primary direction for each pin. in narrow expanded modes, data15 ? data8 and data7 ? data0 are multiplexed into the mcu through port c pins on successive cycles. this register is not in the on-chip map in expanded and peripheral modes. when the mcu is operating in special expanded narrow mode and port c and port d are being used for internal visibility, internal accesses produce full 16-bit information with data15 ? data8 on port c and data7 ? data0 on port d. this allows the mcu to operate at full speed while making 16-bit access information available to external development equipment in a single cycle. in this narrow mode, normal 16-bit accesses to external memory get split into two successive 8-bit accesses on port c alone. address: $0004 bit 7654321bit 0 read: pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 write: reset:00000000 expanded wide and peripheral: data15 data14 data13 data12 data11 data10 data9 data8 expanded narrow: data15/7 data14/6 data13/5 data12/4 data11/3 data10/2 data9/1 data8/0 figure 6-5. port c data register (portc)
bus control and input/output (i/o) registers advance information MC68HC812A4 ? rev. 5.0 motorola bus control and input/output (i/o) 101 6.4.6 port c data direction register read: anytime, if register is in the map write: anytime, if register is in the map ddrc is not in the on-chip map in expanded and peripheral modes. this register determines the primary direction for each port c pin when functioning as a general-purpose i/o port. 1 = associated pin is an output. 0 = associated pin is a high-impedance input. address: $0006 bit 7654321bit 0 read: ddrc7 ddrc6 ddrc5 ddrc4 ddrc3 ddrc2 ddrc1 ddrc0 write: reset:00000000 figure 6-6. port c data direction register (ddrc)
MC68HC812A4 ? rev. 5.0 advance information 102 bus control and input/output (i/o) motorola bus control and input/output (i/o) 6.4.7 port d data register read: anytime, if register is in the map write: anytime, if register is in the map bits pd7 ? pd0 correspond to data lines data7 ? data0. when port d is not used for external data, such as in single-chip mode, these pins can be used as general-purpose i/o or key wakeup signals. ddrd determines the primary direction of each port d pin. in special expanded narrow mode, the external data bus is normally limited to eight bits on port c, but the emulate port d bit (emd) in the mode register can be set to allow port c and port d to be used together to provide single-cycle visibility of internal 16-bit accesses for debugging purposes. if the mode is special narrow expanded and emd is set, port d is configured for data7 ? data0 of visible internal accesses and normal 16-bit external accesses are split into two adjacent 8-bit accesses through port c. this allows connection of a single 8-bit external program memory. this register is not in the on-chip map in wide expanded and peripheral modes. also, in special narrow expanded mode, the function of this port is determined by the emd control bit. if emd is set, this register is not in the on-chip map and port d is used for data7 ? data0 of visible internal accesses. if emd is clear, this port serves as general-purpose i/o or key wakeup signals. address: $0005 bit 7654321bit 0 read: pd7 pd6 pd5 pd4 pd3 pd2 pd1 pd0 write: reset:00000000 expanded wide and peripheral: data7 data6 data5 data4 data3 data2 data1 data0 alternate pin function: kwd7 kwd6 kwd5 kwd4 kwd3 kwd2 kwd1 kwd0 figure 6-7. port d data register (portd)
bus control and input/output (i/o) registers advance information MC68HC812A4 ? rev. 5.0 motorola bus control and input/output (i/o) 103 6.4.8 port d data direction register read: anytime, if register is in the map write: anytime, if register is in the map when port d is operating as a general-purpose i/o port, this register determines the primary direction for each port d pin. 1 = associated pin is an output. 0 = associated pin is a high-impedance input. this register is not in the map in wide expanded and peripheral modes. also, in special narrow expanded mode, the function of this port is determined by the emd control bit. if emd is set, this register is not in the on-chip map and port d is used for data7 ? data0 of visible internal accesses. if emd is clear, this port serves as general-purpose i/o or key wakeup signals. address: $0007 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 6-8. port d data direction register (ddrd)
MC68HC812A4 ? rev. 5.0 advance information 104 bus control and input/output (i/o) motorola bus control and input/output (i/o) 6.4.9 port e data register read: anytime, if register is in the map write: anytime, if register is in the map this register is associated with external bus control signals and interrupt inputs including auxiliary reset (arst), mode select (modb/ipipe1, moda/ipipe0), e-clock, size (lstrb ), read/write (r/w ), irq , and xirq . when the associated pin is not used for one of these specific functions, the pin can be used as general-purpose i/o. the port e assignment register (pear) selects the function of each pin. ddre determines the primary direction of each port e pin when configured to be general-purpose i/o. some of these pins have software selectable pullups (lstrb , r/w , and xirq ). a single control bit enables the pullups for all these pins which are configured as inputs. irq always has a pullup. pe7 can be selected as a high-true auxiliary reset input. this register is not in the map in peripheral mode or expanded modes when the eme bit is set. address: $0008 bit 7654321bit 0 read: pe7 pe6 pe5 pe4 pe3 pe2 pe1 pe0 write: reset: unaffected by reset normal narrow expanded: 0 0 0 0 1 0 0 0 all other modes: 0 0 0 0 0 0 0 0 alternate pin function: arst modb or ipipe1 moda or ipipe0 eclk lstrb r/w irq xirq figure 6-9. port e data register (porte)
bus control and input/output (i/o) registers advance information MC68HC812A4 ? rev. 5.0 motorola bus control and input/output (i/o) 105 6.4.10 port e data direction register read: anytime, if register is in the map write: anytime, if register is in the map this register determines the primary direction for each port e pin configured as general-purpose i/o. 1 = associated pin is an output. 0 = associated pin is a high-impedance input. pe1 and pe0 are associated with xirq and irq and cannot be configured as outputs. these pins can be read regardless of whether the alternate interrupt functions are enabled. this register is not in the map in peripheral mode and expanded modes while the eme control bit is set. address: $0009 bit 7654321bit 0 read: ddre7 ddre6 ddre5 ddre4 ddre3 ddre2 ddre1 ddre0 write: reset:00000011 normal narrow expanded: 0 0 001000 all other modes: 0 0 000000 figure 6-10. port e data direction register (ddre)
MC68HC812A4 ? rev. 5.0 advance information 106 bus control and input/output (i/o) motorola bus control and input/output (i/o) 6.4.11 port e assignment register read: anytime, if register is in the map write: varies from bit to bit if register is in the map the pear register selects between the general-purpose i/o functions and the alternate bus-control functions of port e. the alternate bus-control functions override the associated ddre bits. the reset condition of this register depends on the mode of operation.  in normal single-chip mode, port e is general-purpose i/o.  in special single-chip mode, the e-clock is enabled as a timing reference, and the rest of port e is general-purpose i/o.  in normal expanded modes, the e-clock is configured for its alternate bus-control function, and the other bits of port e are general-purpose i/o. the reset vector is located in external memory and the e-clock may be required for this access. if r/w is needed for external writable resources, pear can be written during normal expanded modes.  in special expanded modes, ipipe1, ipipe0, e, r/w , and lstrb are configured as bus-control signals. address: $000a bit 7654321bit 0 read: arsie pllte pipoe neclk lstre rdwe 0 0 write: reset: special single-chip:00101100 special expanded narrow: 0 0 101100 peripheral: 0 1 010000 special expanded wide: 0 0 101100 normal single-chip00010000 normal expanded narrow: 0 0 000000 normal expanded wide: 0 0 000000 figure 6-11. port e assignment register (pear)
bus control and input/output (i/o) registers advance information MC68HC812A4 ? rev. 5.0 motorola bus control and input/output (i/o) 107 in peripheral mode, the pear register is not accessible for reads or writes. however, the pllte control bit is cleared to configure pe6 as a test output from the pll module. arsie ? auxiliary reset input enable bit write anytime. 1 = pe7 is a high-true reset input; reset timing is the same as that of the low-true reset pin. 0 = pe7 is general-purpose i/o. pllte ? pll testing enable bit normal modes: write never special modes: write anytime except the first time 1 = pe6 is a test signal output from the pll module (no effect in single-chip or normal expanded modes); pipoe = 1 overrides this function and forces pe6 to be a pipe status output signal. 0 = pe6 is general-purpose i/o or pipe output. pipoe ? pipe status signal output enable bit normal modes: write once special modes: write anytime except the first time 1 = pe6 and pe5 are outputs and indicate the state of the instruction queue; no effect in single-chip modes. 0 = pe6 and pe5 are general-purpose i/o; if pllte = 1, pe6 is a test output signal from the pll module. neclk ? no external e clock bit normal modes: write anytime special modes: write never in peripheral mode, e is an input; in all other modes, e is an output. 1 = pe4 is a general-purpose i/o pin. 0 = pe4 is the external e-clock pin. to get a free-running e-clock in single-chip modes, use neclk = 0 and ivis = 1. a 16-bit write to pear:mode can configure these bits in one operation.
MC68HC812A4 ? rev. 5.0 advance information 108 bus control and input/output (i/o) motorola bus control and input/output (i/o) lstre ? low strobe (lstrb ) enable bit normal modes: write once special modes: write anytime except the first time lstre has no effect in single-chip or normal expanded narrow modes. 1 = pe3 is configured as the lstrb bus-control output, except in single-chip or normal expanded narrow modes. 0 = pe3 is a general-purpose i/o pin. lstrb is for external writes. after reset in normal expanded mode, lstrb is disabled. if needed, it must be enabled before external writes. external reads do not normally need lstrb because all 16 data bits can be driven even if the mcu only needs eight bits of data. in normal expanded narrow mode, this pin is reset to an output driving high allowing the pin to be an output while in and immediately after reset. rdwe ? read/write enable bit normal modes: write once special modes: write anytime except the first time rdwe has no effect in single-chip modes. 1 = pe2 is configured as the r/w pin. in single-chip modes, rdwe has no effect and pe2 is a general-purpose i/o pin. 0 = pe2 is a general-purpose i/o pin. r/w is used for external writes. after reset in normal expanded mode, it is disabled. if needed, it must be enabled before any external writes.
bus control and input/output (i/o) registers advance information MC68HC812A4 ? rev. 5.0 motorola bus control and input/output (i/o) 109 6.4.12 pullup control register read: anytime, if register is in the map write: anytime, if register is in the map this register is not in the map in peripheral mode. these bits select pullup resistors for any pin in the corresponding port that is currently configured as an input. puph ? pullup port h enable bit 1 = enable pullup devices for all port h input pins 0 = port h pullups disabled pupg ? pullup port g enable bit 1 = enable pullup devices for all port g input pins 0 = port g pullups disabled pupf ? pullup port f enable bit 1 = enable pullup devices for all port f input pins 0 = port f pullups disabled pupe ? pullup port e enable bit 1 = enable pullup devices for port e input pins pe3, pe2, and pe0 0 = port e pullups on pe3, pe2, and pe0 disabled pupd ? pullup port d enable bit 1 = enable pullup devices for all port d input pins 0 = port d pullups disabled this bit has no effect if port d is being used as part of the data bus (the pullups are inactive). address: $000c bit 7654321bit 0 read: puph pupg pupf pupe pupd puc pupb pupa write: reset:11111111 figure 6-12. pullup control register (pucr)
MC68HC812A4 ? rev. 5.0 advance information 110 bus control and input/output (i/o) motorola bus control and input/output (i/o) pupc ? pullup port c enable bit 1 = enable pullup devices for all port c input pins 0 = port c pullups disabled this bit has no effect if port c is being used as part of the data bus (the pullups are inactive). pupb ? pullup port b enable bit 1 = enable pullup devices for all port b input pins 0 = port b pullups disabled this bit has no effect if port b is being used as part of the address bus (the pullups are inactive). pupa ? pullup port a enable bit 1 = enable pullup devices for all port a input pins 0 = port a pullups disabled this bit has no effect if port a is being used as part of the address bus (the pullups are inactive). 6.4.13 reduced drive register read: anytime, if register is in the map write: anytime, in normal modes; never in special modes this register is not in the map in peripheral mode. these bits select reduced drive for the associated port pins. this gives reduced power consumption and reduced rfi with a slight increase in transition time (depending on loading). the reduced drive function is independent of which function is being used on a particular port. address: $000d bit 7654321bit 0 read: rdpj rdph rdpg rdpf rdpe prpd rdpc rdpab write: reset:00000000 figure 6-13. reduced drive register (rdriv)
bus control and input/output (i/o) registers advance information MC68HC812A4 ? rev. 5.0 motorola bus control and input/output (i/o) 111 rdpj ? reduced drive of port j bit 1 = reduced drive for all port j output pins 0 = full drive for all port j output pins rdph ? reduced drive of port h bit 1 = reduced drive for all port h output pins 0 = full drive for all port h output pins rdpg ? reduced drive of port g bit 1 = reduced drive for all port g output pins 0 = full drive for all port g output pins rdpf ? reduced drive of port f bit 1 = reduced drive for all port f output pins 0 = full drive for all port f output pins rdpe ? reduced drive of port e bit 1 = reduced drive for all port e output pins 0 = full drive for all port e output pins rdpd ? reduced drive of port d bit 1 = reduced drive for all port d output pins 0 = full drive for all port d output pins rdpc ? reduced drive of port c bit 1 = reduced drive for all port c output pins 0 = full drive for all port c output pins rdpab ? reduced drive of port a and port b bit 1 = reduced drive for all port a and port b output pins 0 = full drive for all port a and port b output pins
MC68HC812A4 ? rev. 5.0 advance information 112 bus control and input/output (i/o) motorola bus control and input/output (i/o)
advance information MC68HC812A4 ? rev. 5.0 motorola eeprom 113 advance information ? MC68HC812A4 section 7. eeprom 7.1 contents 7.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113 7.3 eeprom programmer ? s model . . . . . . . . . . . . . . . . . . . . . . .114 7.4 eeprom control registers . . . . . . . . . . . . . . . . . . . . . . . . . . 116 7.4.1 eeprom module configuration register . . . . . . . . . . . . .116 7.4.2 eeprom block protect register . . . . . . . . . . . . . . . . . . . . 117 7.4.3 eeprom test register . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 7.4.4 eeprom programming register . . . . . . . . . . . . . . . . . . . .119 7.2 introduction the MC68HC812A4 eeprom (electrically erasable, programmable, read-only memory) serves as a 4096-byte nonvolatile memory which can be used for frequently accessed static data or as fast access program code. operating system kernels and standard subroutines would benefit from this feature. the MC68HC812A4 eeprom is arranged in a 16-bit configuration. the eeprom array may be read as either bytes, aligned words, or misaligned words. access times are one bus cycle for byte and aligned word access and two bus cycles for misaligned word operations. programming is by byte or aligned word. attempts to program or erase misaligned words will fail. only the lower byte will be latched and programmed or erased. programming and erasing of the user eeprom can be done in all modes.
MC68HC812A4 ? rev. 5.0 advance information 114 eeprom motorola eeprom each eeprom byte or aligned word must be erased before programming. the eeprom module supports byte, aligned word, row (32 bytes), or bulk erase, all using the internal charge pump. bulk erasure of odd and even rows is also possible in test modes; the erased state is $ff. the eeprom module has hardware interlocks which protect stored data from corruption by accidentally enabling the program/erase voltage. programming voltage is derived from the internal v dd supply with an internal charge pump. the eeprom has a minimum program/erase life of 10,000 cycles over the complete operating temperature range. 7.3 eeprom programmer ? s model the eeprom module consists of two separately addressable sections. the first is a 4-byte memory mapped control register block used for control, testing and configuration of the eeprom array. the second section is the eeprom array itself. at reset, the 4-byte register section starts at address $00f0 and the eeprom array is located from addresses $1000 to $1fff (see figure 7-1 ). for information on remapping the register block and eeprom address space, refer to section 5. operating modes and resource mapping . read/write access to the memory array section can be enabled or disabled by the eeon control bit in the initee register. this feature allows the access of memory mapped resources that have lower priority than the eeprom memory array. eeprom control registers can be accessed and eeprom locations may be programmed or erased regardless of the state of eeon. using the normal eeprog control, it is possible to continue program/erase operations during wait. for lowest power consumption during wait, stop program/erase by turning off eepgm.
eeprom eeprom programmer ? s model advance information MC68HC812A4 ? rev. 5.0 motorola eeprom 115 if the stop mode is entered during programming or erasing, program/erase voltage is automatically turned off and the rc clock (if enabled) is stopped. however, the eepgm control bit remains set. when stop mode is terminated, the program/erase voltage automatically turns back on if eepgm is set. at low bus frequencies, the rc clock must be turned on for program/erase. figure 7-1. eeprom block protect mapping bprot0 64 bytes bprot6 bprot5 bprot4 bprot3 bprot2 bprot1 $_000 $_800 $_c00 $_e00 $_f00 $_f80 $_fc0 $_fff 2 kbytes 1 kbyte 512 bytes 256 bytes 128 bytes 64 bytes reserved 64 bytes vectors 64 bytes single-chip vectors $ff80 $ffbf $ffc0 $ffff
MC68HC812A4 ? rev. 5.0 advance information 116 eeprom motorola eeprom 7.4 eeprom control registers this section describes the eeprom control registers. 7.4.1 eeprom module configuration register read: anytime write: varies from bit to bit eeswai ? eeprom stops in wait mode bit 0 = module is not affected during wait mode. 1 = module ceases to be clocked during wait mode. this bit should be cleared if the wait mode vectors are mapped in the eeprom array. protlck ? block protect write lock bit 0 = block protect bits and bulk erase protection bit can be written. 1 = block protect bits are locked. write once in normal modes (smodn = 1). set and clear anytime in special modes (smodn = 0). eerc ? eeprom charge pump clock bit 0 = system clock is used as clock source for the internal charge pump; internal rc oscillator is stopped. 1 = internal rc oscillator drives the charge pump; rc oscillator is required when the system bus clock is lower than f prog . write: anytime address: $00f0 bit 7654321bit 0 read: 11111eeswaiprotlckeerc write: reset:11111100 figure 7-2. eeprom module configuration register (eemcr)
eeprom eeprom control registers advance information MC68HC812A4 ? rev. 5.0 motorola eeprom 117 7.4.2 eeprom block protect register read: anytime write: anytime if eepgm = 0 and protlck = 0 this register prevents accidental writes to eeprom. bprot6 ? bprot0 ? eeprom block protection bit 0 = associated eeprom block can be programmed and erased. 1 = associated eeprom block is protected from being programmed and erased. these bits cannot be modified while programming is taking place (eepgm = 1). address: $00f1 bit 7654321bit 0 read: 1 bprot6 bprot5 bprot4 bprot3 bprot2 bprot1 bprot0 write: reset:11111111 figure 7-3. eeprom block protect register (eeprot) table 7-1. 4-kbyte eeprom block protection bit name block protected block size bprot6 $1000 to $17ff 2048 bytes bprot5 $1800 to $1bff 1024 bytes bprot4 $1c00 to $1dff 512 bytes bprot3 $1e00 to $1eff 256 bytes bprot2 $1f00 to $1f7f 128 bytes bprot1 $1f80 to $1fbf 64 bytes bprot0 $1fc0 to $1fff 64 bytes
MC68HC812A4 ? rev. 5.0 advance information 118 eeprom motorola eeprom 7.4.3 eeprom test register read: anytime write: in special modes only (smodn = 0) these bits are used for test purposes only. in normal modes, the bits are forced to 0. eeodd ? odd row programming bit 1 = bulk program/erase all odd rows 0 = odd row bulk programming/erasing disabled eeven ? even row programming bit 1 = bulk program/erase all even rows 0 = even row bulk programming/erasing disabled marg ? program and erase voltage margin test enable bit 1 = program and erase margin test 0 = normal operation this bit is used to evaluate the program/erase voltage margin. eecpd ? charge pump disable bit 1 = disable charge pump 0 = charge pump is turned on during program/erase eecprd ? charge pump ramp disable bit 1 = disable charge pump controlled ramp up 0 = charge pump is turned on progressively during program/erase this bit is known to enhance write/erase endurance of eeprom cells. ecpm ? charge pump monitor enable bit 1 = output the charge pump voltage on the irq /v pp pin 0 = normal operation address: $00f2 bit 7654321bit 0 read: eeodd eeven marg eecpd eecprd 0 eecpm 0 write: reset:00000000 = unimplemented figure 7-4. eeprom test register (eeprot)
eeprom eeprom control registers advance information MC68HC812A4 ? rev. 5.0 motorola eeprom 119 7.4.4 eeprom programming register read: anytime write: varies from bit to bit bulkp ? bulk erase protection bit 1 = eeprom protected from bulk or row erase 0 = eeprom can be bulk erased. write anytime, if eepgm = 0 and protlck = 0 byte ? byte and aligned word erase bit 1 = one byte or one aligned word erase only 0 = bulk or row erase enabled write anytime, if eepgm = 0 row ? row or bulk erase bit (when byte = 0) 1 = erase only one 32-byte row 0 = erase entire eeprom array write anytime, if eepgm = 0 byte and row have no effect when erase = 0. address: $00f3 bit 7654321bit 0 read: bulkp 0 0 byte row erase eelat eepgm write: reset:10000000 figure 7-5. eeprom programming register (eeprog) table 7-2. erase selection byte row block size 0 0 bulk erase entire eeprom array 0 1 row erase 32 bytes 1 0 byte or aligned word erase 1 1 byte or aligned word erase
MC68HC812A4 ? rev. 5.0 advance information 120 eeprom motorola eeprom if byte = 1 and test mode is not enabled, only the location specified by the address written to the programming latches is erased. the operation is a byte or an aligned word erase depending on the size of written data. erase ? erase control bit 1 = eeprom configuration for erasure 0 = eeprom configuration for programming write anytime, if eepgm = 0 this bit configures the eeprom for erasure or programming. eelat ? eeprom latch control bit 1 = eeprom address and data bus latches set up for programming or erasing 0 = eeprom set up for normal reads write: anytime, if eepgm = 0 note: when eelat is set, the entire eeprom is unavailable for reads; therefore, no program residing in the eeprom can be executed while attempting to program unused eeprom space. care should be taken that no references to the eeprom are used while programming. interrupts should be turned off if the vectors are in the eeprom. timing and any serial communications must be done with polling during the programming process. byte, row, erase, and eelat bits can be written simultaneously or in any sequence. eepgm ? program and erase enable bit 1 = applies program/erase voltage to eeprom 0 = disables program/erase voltage to eeprom the eepgm bit can be set only after eelat has been set. when eelat and eepgm are set simultaneously, eepgm remains clear but eelat is set. the bulkp, byte, row, erase, and eelat bits cannot be changed when eepgm is set. to complete a program or erase, two successive writes to clear eepgm and eelat bits are required before reading the programmed data. a write to an eeprom location has no effect when eepgm is set. latched address and data cannot be modified during program or erase.
eeprom eeprom control registers advance information MC68HC812A4 ? rev. 5.0 motorola eeprom 121 a program or erase operation should follow this sequence: 1. write byte, row, and erase to the desired value; write eelat = 1. 2. write a byte or an aligned word to an eeprom address. 3. write eepgm = 1. 4. wait for programming ( t prog ) or erase ( t erase ) delay time. 5. write eepgm = 0. 6. write eelat = 0. by jumping from step 5 to step 2, it is possible to program/erase more bytes or words without intermediate eeprom reads.
MC68HC812A4 ? rev. 5.0 advance information 122 eeprom motorola eeprom
advance information MC68HC812A4 ? rev. 5.0 motorola memory expansion and chip-select 123 advance information ? MC68HC812A4 section 8. memory expansion and chip-select 8.1 contents 8.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124 8.3 generation of chip-selects. . . . . . . . . . . . . . . . . . . . . . . . . . .126 8.3.1 chip-selects independent of memory expansion . . . . . . .126 8.3.2 chip-selects used in conjunction with memory expansion . . . . . . . . . . . . . . . . . . . . . . . .128 8.4 chip-select stretch. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130 8.5 memory expansion registers. . . . . . . . . . . . . . . . . . . . . . . . .132 8.5.1 port f data register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .132 8.5.2 port g data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . .132 8.5.3 port f data direction register . . . . . . . . . . . . . . . . . . . . . .133 8.5.4 port g data direction register. . . . . . . . . . . . . . . . . . . . . . 133 8.5.5 data page register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134 8.5.6 program page register . . . . . . . . . . . . . . . . . . . . . . . . . . .134 8.5.7 extra page register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .135 8.5.8 window definition register . . . . . . . . . . . . . . . . . . . . . . . . 135 8.5.9 memory expansion assignment register . . . . . . . . . . . . .136 8.6 chip-selects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137 8.7 chip-select registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 8.7.1 chip-select control register 0. . . . . . . . . . . . . . . . . . . . . .138 8.7.2 chip-select control register 1. . . . . . . . . . . . . . . . . . . . . .140 8.7.3 chip-select stretch registers . . . . . . . . . . . . . . . . . . . . . .141 8.8 priority. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .142
MC68HC812A4 ? rev. 5.0 advance information 124 memory expansion and chip-select motorola memory expansion and chip-select 8.2 introduction to use memory expansion, the mcu must be operated in one of the expanded modes. sections of the standard 64-kbyte address space have memory expansion windows which allow an external address space larger than 64 kbytes. memory expansion consists of three memory expansion windows and six address lines which are used in addition to the standard 16 address lines. the memory expansion function reuses as many as six of the standard 16 address lines. to do this, some of the upper address lines of internal addresses falling in an active window are overridden. consequently, the address viewed externally may not match the internal address. usage of chip-selects identify the source of the internal address for debugging and selection of the proper external devices. all memory expansion windows have a fixed size and two have a fixed address location. the third has two selectable address locations. when an internal address falls into one of these active windows, it is translated as shown in table 8-1 . addresses addr9 ? addr0 are not affected by memory expansion and are the same externally as they are internally. addresses addr21 ? addr16 are generated only by memory expansion and are individually enabled by software-programmable control bits. if not enabled, they may be used as general-purpose i/o (input/output). addresses addr15 ? addr10 can be the internal addresses or they can be modified by the memory expansion module. these are not available as general-purpose i/o in expanded modes.
memory expansion and chip-select introduction advance information MC68HC812A4 ? rev. 5.0 motorola memory expansion and chip-select 125 table 8-1. memory expansion values (1) internal address a21a20a19a18a17a16a15a14a13a12a11a10 $0000 ? $03ff ewdir (2) = 1, ewen = 1 1 1 1 1 pea17 pea16 pea15 pea14 pea13 pea12 pea11 pea10 $0000 ? $03ff ewdir or ewen = 0 111111a15a14a13a12a11a10 $0400 ? $07ff ewdir = 0, ewen = 1 1 1 1 1 pea17 pea16 pea15 pea14 pea13 pea12 pea11 pea10 $0400 ? $07ff ewdir = 1, ewen = x or ewdir = x, ewen = 0 111111a15a14a13a12a11a10 $0800 ? $6fff111111a15a14a13a12a11a10 $7000 ? $7fff dwen = 1 1 1 pda19 pda18 pda17 pda16 pda15 pda14 pda13 pda12 a11 a10 $7000 ? $7fff dwen = 0 111111a15a14a13a12a11a10 $8000 ? $bfff pwen = 1 ppa21 ppa20 ppa19 ppa18 ppa17 ppa16 ppa15 ppa14 a13 a12 a11 a10 $8000 ? $bfff pwen = 0 111111a15a14a13a12a11a10 $c000 ? $ffff 1 1 1111a15a14a13a12a11a10 1. all port g assigned to memory expansion 2. the ewdir bit in the misc register selects the e window address (1 = $0000 ? $03ff including direct space and 0 = $0400 ? $07ff).
MC68HC812A4 ? rev. 5.0 advance information 126 memory expansion and chip-select motorola memory expansion and chip-select 8.3 generation of chip-selects to use chip-selects the mcu must be in one of the expanded modes. each of the seven chip-selects has an address space for which it is active ? that is, when the current cpu address is in the range of that chip-select, it becomes active. chip-selects are generally used to reduce or eliminate external address decode logic. these active low signals usually are connected directly to the chip-select pin of an external device. 8.3.1 chip-selects independent of memory expansion three types of chip-selects are program memory chip-selects, other memory chip-selects and peripheral chip-selects. memory chip-selects cover a medium-to-large address space. peripheral chip-selects (cs3 ? cs0) cover a small address space. the program memory chip-select includes the vector space and is generally used with non-volatile memory. to start the user ? s program, the program chip-select is designed to be active out of reset. this is the only chip-select which has a functional difference from the others, so a small memory could use a peripheral chip-select and a peripheral could use a memory chip-select. figure 8-1 shows peripheral chip-selects in an expanded portion of the memory map. table 8-2 shows the register settings that correspond to the example. chip-selects cs2 ? cs0 always map to the same 2-kbyte block as the internal register space. the internal registers cover the first 512 bytes and these chip-selects cover all or part of the 512 bytes following the register space blocking out a full 1-kbyte space. cs3 can map with these other chip-selects or be used in a 1-kbyte space by itself which starts at either $0000 or $0400. cs3 can be used only for a 1-kbyte space when it selects the e page of memory expansion and e page is active.
memory expansion and chip-select generation of chip-selects advance information MC68HC812A4 ? rev. 5.0 motorola memory expansion and chip-select 127 figure 8-1. chip-selects cs3 ? cs0 partial memory map table 8-2. example register settings register value meaning initrm $00 assigns internal ram to $0000 ? $0fff initrg $08 assigns register block to $0800 ? $09ff and register-following chip-selects at $0a00 ? $0bff windef $20 enable epage mxar $00 no port g lines assigned as extended address $0000 $0100 $0200 $0300 $0400 $0500 $0600 $0700 $0800 $0900 $0a00 $0b00 $0c00 $0d00 $0e00 $0f00 $0fff internal space ram 1 kbyte registers external space cs0 cs1 256 bytes 128 bytes 128 bytes 1 kbyte cs3 cs2
MC68HC812A4 ? rev. 5.0 advance information 128 memory expansion and chip-select motorola memory expansion and chip-select cs3 can be used with a 1-kbyte space in systems not using memory expansion. however, it must be made to appear as if memory expansion is in use. one of many possible configurations is:  select the desired 1-kbyte space for epage (ewdir in misc in the mmi).  write the epage register with $0000, if ewdir is one or $0001 if ewdir is 0.  designate all port g pins as i/o.  enable epage and cs3.  make cs3 follow epage. 8.3.2 chip-selects used in conjunction with memory expansion memory expansion and chip-select functions can work independently, but systems requiring memory expansion perform better when chip-selects are also used. for each memory expansion window there is a chip-select (or two) designed to function with it. figure 8-2 shows a memory expansion and chip-select example using three chip-selects. table 8-3 shows the register settings that correspond to the example. the program space consists of 128 kbytes of addressable memory in eight 16-kbyte pages. page 7 is always accessible in the space from $c000 to $ffff. the data space consists of 64 kbytes of addressable memory in 16, 4-kbyte pages. unless csd is used to select the external ram, pages 0 through 6 appear in the $0000 to $6fff space wherever there is no higher priority resource. the csctl0 $xf enables cs3, cs2, cs1, and cs0 csctl1 $x8 makes cs3 follow epage misc %0xxxxxxx puts epage at $0400 ? $07ff epage $01 keeps the translated value of the upper addresses the same as it would have been before translation; not necessary if all external devices use chip-selects table 8-2. example register settings (continued) register value meaning
memory expansion and chip-select generation of chip-selects advance information MC68HC812A4 ? rev. 5.0 motorola memory expansion and chip-select 129 extra space consists of four, 1-kbyte pages making 4 kbytes of addressable memory. if memory is increased to the maximum in this example, the program space will consist of 4 mbytes of addressable space with 256 16-kbyte pages and page $ff always available. the data space will be 1 mbyte of addressable space with 256 4-kbyte pages and pages $f0 to $f6 mirrored to the $0000 to $6fff space. the extra space will be 256 kbytes of addressable space in 256 1-kbyte pages. figure 8-2. memory expansion and chip-select example $0000 $1000 $2000 $3000 $4000 $5000 $6000 $7000 $8000 $9000 $a000 $b000 $c000 $d000 $e000 $f000 $ffff $ffc0 ? $ffff 0 1 2 3 4 5 6 page 7 data chip-select: (csd) $0000 to $7fff data window: $7000 to $7fff program chip-select 0: (csp0) $8000 to $ffff program pages: $8000 to $bfff 0 1 2 page 3 chip-select 3: (cs3) $0400 to $07ff external space internal space registers & ram & cs[3:0] eeprom vectors note 2 x4 x5 x6 x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe page xf note 1: some 4-kbyte blocks of phys- ical external data memory can be se- lected by an access to $0000 ? $6fff in the 64-kbyte map or as pages 0 through 6 in the data window. on-chip registers, eeprom, and epage have higher priority than csd. note 2: the last page of physical pro- gram memory can be selected by an access to $c000 ? $ffff in the 64-kbyte map or as page 7 in the pro- gram window. note 1 . . .
MC68HC812A4 ? rev. 5.0 advance information 130 memory expansion and chip-select motorola memory expansion and chip-select 8.4 chip-select stretch each chip-select can be chosen to stretch bus cycles associated with it. stretch can be zero, one, two, or three whole cycles added which allows interfacing to external devices which cannot meet full bus speed timing. figure 8-3 , figure 8-4 , figure 8-5 , and figure 8-6 show the waveforms for zero to three cycles of stretch. figure 8-3. chip-select with no stretch figure 8-4. chip-select with 1-cycle stretch table 8-3. example register settings register value meaning windef $e0 enable epage, dpage, ppage mxar $01 port g bit 0 assigned as extended address addr16 csctl0 %00111xxx enables csp0, csd, and cs3 csctl1 $18 makes csd follow $0000 ? $7fff and cs3 select epage misc %0xxxxxxx puts epage at $0400 ? $09ff unstretched bus cycle cs internal e-clock eclk pin cs stretched internal e-clock eclk pin stretched by 1 cycle
memory expansion and chip-select chip-select stretch advance information MC68HC812A4 ? rev. 5.0 motorola memory expansion and chip-select 131 figure 8-5. chip-select with 2-cycle stretch figure 8-6. chip-select with 3-cycle stretch the external e-clock may be the stretched e-clock, the e-clock, or no clock depending on the selection of control bits estr and ivis in the mode register and neclk in the pear register. cs stretched internal stretched by 2 cycles e-clock eclk pin stretched by 3 cycles cs stretched internal e-clock eclk pin
MC68HC812A4 ? rev. 5.0 advance information 132 memory expansion and chip-select motorola memory expansion and chip-select 8.5 memory expansion registers this section describes the memory expansion registers. 8.5.1 port f data register read: anytime write: anytime seven port f pins are associated with chip-selects. any pin not used as a chip-select can be used as general-purpose i/o. all pins are pulled up when inputs (if pullups are enabled). enabling a chip-select overrides the associated data direction bit and port data bit. 8.5.2 port g data register read: anytime write: anytime six port g pins are associated with memory expansion. any pin not used for memory expansion can be used as general-purpose i/o. all pins are pulled up when inputs (if pullups are enabled). enabling a memory expansion address with the memory expansion assignment register overrides the associated data direction bit and port data bit. address: $0030 bit 7654321bit 0 read: 0 pf6 pf5 pf4 pf3 pf2 pf1 pf0 write: reset:00000000 = unimplemented alternate pin function: csp1 csp0 csd cs3 cs2 cs1 cs0 figure 8-7. port f data register (portf) address: $0031 bit 7654321bit 0 read: 0 0 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset:00000000 = unimplemented alternate pin function: addr21 addr20 addr19 addr18 addr17 addr16 figure 8-8. port g data register (portg)
memory expansion and chip-select memory expansion registers advance information MC68HC812A4 ? rev. 5.0 motorola memory expansion and chip-select 133 8.5.3 port f data direction register read: anytime write: anytime when port f is active, ddrf determines pin direction. 1 = associated bit is an output. 0 = associated bit is an input. 8.5.4 port g data direction register read: anytime write: anytime when port g is active, ddrg determines pin direction. 1 = associated bit is an output. 0 = associated bit is an input. address: $0032 bit 7654321bit 0 read: 0 ddrf6 ddrf5 ddrf4 ddrf3 ddrf2 ddrf1 ddrf0 write: reset:00000000 = unimplemented figure 8-9. port f data direction register (ddrf) address: $0033 bit 7654321bit 0 read: 0 0 ddrg5 ddrg4 ddrg3 ddrg2 ddrg1 ddrg0 write: reset:00000000 = unimplemented figure 8-10. port g data direction register (ddrg)
MC68HC812A4 ? rev. 5.0 advance information 134 memory expansion and chip-select motorola memory expansion and chip-select 8.5.5 data page register read: anytime write: anytime when enabled (dwen = 1), the value in this register determines which of the 256 4-kbyte pages is active in the data window. an access to the data page memory area ($7000 to $7fff) forces the contents of dpage to address pins addr15 ? addr12 and expansion address pins addr19 ? addr16. bits addr20 and addr21 are forced to 1 if enabled by mxar. data chip-select (csd) must be used in conjunction with this memory expansion window. 8.5.6 program page register read: anytime write: anytime when enabled (pwen = 1), the value in this register determines which of the 256 16-kbyte pages is active in the program window. an access to the program page memory area ($8000 to $bfff) forces the contents of ppage to address pins addr15 ? addr14 and expansion address pins addr21 ? addr16. at least one of the program chip-selects (csp0 or csp1) must be used in conjunction with this memory expansion window. this register is used by the call and rtc instructions to facilitate automatic program flow changing between pages of program memory. address: $0034 bit 7654321bit 0 read: pd19 pd18 pd17 pd16 pd15 pd14 pd13 pd12 write: reset:00000000 figure 8-11. data page register (dpage) address: $0035 bit 7654321bit 0 read: ppa21 ppa20 ppa19 ppa18 ppa17 ppa16 ppa15 ppa14 write: reset:00000000 figure 8-12. program page register (ppage)
memory expansion and chip-select memory expansion registers advance information MC68HC812A4 ? rev. 5.0 motorola memory expansion and chip-select 135 8.5.7 extra page register read: anytime write: anytime when enabled (ewen = 1), the value in this register determines which of the 256 1-kbyte pages is active in the extra window. an access to the extra page memory area forces the contents of epage to address pins addr15 ? addr10 and expansion address pins addr16 ? addr17. address bits addr21 ? addr18 are forced to one (if enabled by mxar). chip-select 3 set to follow the extra page window (cs3 with cs3ep = 1) must be used in conjunction with this memory expansion window. 8.5.8 window definition register read: anytime write: anytime dwen ? data window enable bit 1 = enables paging of the data space (4 kbytes: $7000 ? $7fff) via the dpage register 0 = disables dpage address: $0036 bit 7654321bit 0 read: pea17 pea16 pea15 pea14 pea13 pea12 pea11 pea10 write: reset:00000000 figure 8-13. extra page register (epage) address: $0037 bit 7654321bit 0 read: dwenpwenewen00000 write: reset:00000000 figure 8-14. window definition register (windef)
MC68HC812A4 ? rev. 5.0 advance information 136 memory expansion and chip-select motorola memory expansion and chip-select pwen ? program window enable bit 1 = enables paging of the program space (16 kbytes: $8000 ? $bfff) via the ppage register 0 = disables ppage ewen ? extra window enable bit 1 = enables paging of the extra space (1 kbyte) via the epage register 0 = disables epage 8.5.9 memory expansion assignment register read: anytime write: anytime a21e, a20e, a19e, a18e, a17e, and a16e ? these bits select the memory expansion pins addr21 ? addr16. 1 = selects memory expansion for the associated bit function, overrides ddrg 0 = selects general-purpose i/o for the associated bit function in single-chip modes, these bits have no effect. address: $0038 bit 7654321bit 0 read: 0 0 a21e a20e a19e a18e a17e a16e write: reset:00000000 = unimplemented figure 8-15. memory expansion assignment register (mxar)
memory expansion and chip-select chip-selects advance information MC68HC812A4 ? rev. 5.0 motorola memory expansion and chip-select 137 8.6 chip-selects the chip-selects are all active low. all pins in the associated port are pulled up when they are inputs and the pupf bit in pucr is set. if memory expansion is used, usually chip-selects should be used as well, since some translated addresses can be confused with untranslated addresses that are not in an expansion window. in single-chip modes, enabling the chip-select function does not affect the associated pins. the block of register-following chip-selects cs3 ? cs0 allows many combinations including:  512-byte cs0  256-byte cs0 and 256-byte cs1  256-byte cs0, 128-byte cs1, and 128-byte cs2  128-byte cs0, 128-byte cs1, 128-byte cs2, and 128-byte cs3 these register-following chip-selects are available in the 512-byte space next to and higher in address than the 512-byte space which includes the registers. for example, if the registers are located at $0800 to $09ff, then these register-following chip-selects are available in the space from $0a00 to $0bff.
MC68HC812A4 ? rev. 5.0 advance information 138 memory expansion and chip-select motorola memory expansion and chip-select 8.7 chip-select registers this section describes the chip-select registers. 8.7.1 chip-select control register 0 read: anytime write: anytime bits have no effect on the associated pin in single-chip modes. csp1e ? chip-select program 1 enable bit this bit effectively selects the holes in the memory map. it can be used in conjunction with csp0 to select between two 2-mbyte devices based on address addr21. 1 = enables this chip-select which covers the space $8000 to $ffff or full map $0000 to $ffff 0 = disables this chip-select csp0e ? chip-select program 0 enable bit 1 = enables this chip-select which covers the program space $8000 to $ffff 0 = disables this chip-select csde ? chip-select data enable bit 1 = enables this chip-select which covers either $0000 to $7fff (csdhf = 1) or $7000 to $7fff (csdhf = 0) 0 = disables this chip-select address: $003c bit 7654321bit 0 read: 0 csp1e csp0e csde cs3e cs2e cs1e cs0e write: reset:00100000 = unimplemented figure 8-16. chip-select control register 0 (csctl0)
memory expansion and chip-select chip-select registers advance information MC68HC812A4 ? rev. 5.0 motorola memory expansion and chip-select 139 cs3e ? chip-select 3 enable bit 1 = enables this chip-select which covers a 128-byte space following the register space ($x280 ? $x2ff or $xa80 ? $xaff) alternately, it can be active for accesses within the extra page window. 0 = disables this chip-select cs2e ? chip-select 2 enable bit 1 = enables this chip-select which covers a 128-byte space following the register space ($x380 ? $x3ff or $xb80 ? $xbff) 0 = disables this chip-select cs1e ? chip-select 1 enable bit cs2 and cs3 have a higher precedence and can override cs1 for a portion of this space. 1 = enables this chip-select which covers a 256-byte space following the register space ($x300 ? $x3ff or $xb00 ? $xbff) 0 = disables this chip-select cs0e ? chip-select 0 enable bit cs1, cs2, and cs3 have higher precedence and can override cs0 for portions of this space. 1 = enables this chip-select which covers a 512-byte space following the register space ($x200 ? $x3ff or $xa00 ? $xbff) 0 = disables this chip-select
MC68HC812A4 ? rev. 5.0 advance information 140 memory expansion and chip-select motorola memory expansion and chip-select 8.7.2 chip-select control register 1 read: anytime write: anytime csp1fl ? program chip-select 1 covers full map 1 = if cspa21 is cleared, chip-select program 1 covers the entire memory map. if cspa21 is set, this bit has no meaning or effect. 0 = if cspa21 is cleared, chip-select program 1 covers half the map, $8000 to $ffff. if cspa21 is set, this bit has no meaning or effect. cspa21 ? program chip-select split based on addr21 setting this bit allows two 2-mbyte memories to make up the 4-mbyte addressable program space. since addr21 is always one in the unpaged $c000 to $ffff space, csp0 is active in this space. 1 = program chip-selects are both active (if enabled) for space $8000 to $ffff; csp0 if addr21 is set and csp1 if addr21 is cleared. 0 = csp0 and csp1 do not rely on addr21. csdhf ? data chip-select covers half the map 1 = data chip-select covers half the memory map ($0000 to $7fff) including the optional data page window ($7000 to $7fff). 0 = data chip-select covers only $7000 to $7fff (the optional data page window). address: $003d bit 7654321bit 0 read: 0 csp1fl cspa21 csdhf cs3ep 000 write: reset:00000000 = unimplemented figure 8-17. chip-select control register 1 (csctl1)
memory expansion and chip-select chip-select registers advance information MC68HC812A4 ? rev. 5.0 motorola memory expansion and chip-select 141 cs3ep ? chip-select 3 follows extra page 1 = chip-select 3 follows accesses to the 1-kbyte extra page ($0400 to $07ff or $0000 to $03ff). any accesses to this window cause the chip-select to go active. (ewen must be set to 1.) 0 = chip-select 3 includes only accesses to a 128-byte space following the register space. 8.7.3 chip-select stretch registers each of the seven chip-selects has a 2-bit field in this register which determines the amount of clock stretch for accesses in that chip-select space. read: anytime write: anytime address: $003e bit 7654321bit 0 read: 0 0 srp1a srp1b srp0a srp0b strda strdb write: reset:00111111 = unimplemented figure 8-18. chip-select stretch register 0 (csstr0) address: $003f bit 7654321bit 0 read: str3a str3b str2a str2b str1a str1b str0a str0b write: reset:00111111 figure 8-19. chip-select stretch register 1 (csstr1)
MC68HC812A4 ? rev. 5.0 advance information 142 memory expansion and chip-select motorola memory expansion and chip-select 8.8 priority only one module or chip-select may be selected at a time. if more than one module shares a space, only the highest priority module is selected. table 8-4. stretch bit definition stretch bit sxxxa stretch bit sxxxb number of e-clocks stretched 00 0 01 1 10 2 11 3 table 8-5. module priorities priority module or space highest on-chip register space ? 512 bytes fully blocked for registers although some of this space is unused bdm space (internal) ? when bdm is active, this 256-byte block of registers and rom appear at $ffxx; cannot overlap ram or registers on-chip ram on-chip eeprom (if enabled, eeon = 1) e space (external) (1) ? 1 kbyte at either $0000 to $03ff or $0400 to $07ff; may be used with ? extra ? memory expansion and cs3 1. external spaces can be accessed only if the mcu is in expanded mode. priorities of differ- ent external spaces affect chip-selects and memory expansion. cs space (external) (1) ? 512 bytes following the 512-byte register space; may be used with cs3 ? cs0 p space (external) (1) ? 16 kbytes fixed at $8000 to $bfff; may be used with program memory expansion and csp0 and/or csp1 d space (external) (1) ? 4 kbytes fixed at $7000 to $7fff; may be used with data memory expansion and csd or csp1 (if set for full memory space) or the entire half of memory space $0000 ? $7fff lowest remaining external (1)
memory expansion and chip-select priority advance information MC68HC812A4 ? rev. 5.0 motorola memory expansion and chip-select 143 only one chip-select is active at any address. in the event that two or more chip-selects cover the same address, only the highest priority chip-select is active. chip-selects have this order of priority: highest lowest cs3 cs2 cs1 cs0 csp0 csd csp1
MC68HC812A4 ? rev. 5.0 advance information 144 memory expansion and chip-select motorola memory expansion and chip-select
advance information MC68HC812A4 ? rev. 5.0 motorola key wakeups 145 advance information ? MC68HC812A4 section 9. key wakeups 9.1 contents 9.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .145 9.3 key wakeup registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .146 9.3.1 port d data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . .146 9.3.2 port d data direction register . . . . . . . . . . . . . . . . . . . . . .147 9.3.3 port d key wakeup interrupt enable register . . . . . . . . . .147 9.3.4 port d key wakeup flag register . . . . . . . . . . . . . . . . . . .148 9.3.5 port h data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . .148 9.3.6 port h data direction register . . . . . . . . . . . . . . . . . . . . . .149 9.3.7 port h key wakeup interrupt enable register . . . . . . . . . .149 9.3.8 port h key wakeup flag register . . . . . . . . . . . . . . . . . . .150 9.3.9 port j data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .150 9.3.10 port j data direction register . . . . . . . . . . . . . . . . . . . . . .151 9.3.11 port j key wakeup interrupt enable register . . . . . . . . . .151 9.3.12 port j key wakeup flag register . . . . . . . . . . . . . . . . . . .152 9.3.13 port j key wakeup polarity register . . . . . . . . . . . . . . . . .152 9.3.14 port j pullup/pulldown select register . . . . . . . . . . . . . . .153 9.3.15 port j pullup/pulldown enable register. . . . . . . . . . . . . . .154 9.2 introduction the key wakeup feature of the MC68HC812A4 issues an interrupt that wakes up the cpu when it is in stop or wait mode. three ports are associated with the key wakeup function: port d, port h, and port j. port d and port h wakeups are triggered with a falling signal edge. port j key wakeups have a selectable falling or rising signal edge as the active edge. for each pin which has an interrupt enabled, there is a path to the interrupt request signal which has no clocked devices when the part is in stop mode. this allows an active edge to bring the part out of stop.
MC68HC812A4 ? rev. 5.0 advance information 146 key wakeups motorola key wakeups default register addresses, as established after reset, are indicated in the following descriptions. for information on remapping the register block, refer to section 5. operating modes and resource mapping . 9.3 key wakeup registers this section provides a summary of the key wakeup registers. 9.3.1 port d data register this register is not in the map in wide expanded modes or in special expanded narrow mode with mode register bit emd set. an interrupt is generated when a bit in the kwifd register and its corresponding kwied bit are both set. these bits correspond to the pins of port d. all eight bits/pins share the same interrupt vector and can wake the cpu when it is in stop or wait mode. key wakeups can be used with the pins configured as inputs or outputs. key wakeup port d shares a vector and control bit with irq . irqen must be set for key wakeup interrupts to signal the cpu. address: $0005 bit 7654321bit 0 read: pd7 pd6 pd5 pd4 pd3 pd2 pd1 pd0 write: reset:00000000 alternate pin function: kwd7 kwd6 kwd5 kwd4 kwd3 kwd2 kwd1 kwd0 figure 9-1. port d data register (portd)
key wakeups key wakeup registers advance information MC68HC812A4 ? rev. 5.0 motorola key wakeups 147 9.3.2 port d data direction register read: anytime write: anytime this register is not in the map in wide expanded modes or in special expanded narrow mode with mode register bit emd set. data direction register d is associated with port d and designates each pin as an input or output. ddrd7 ? ddrd0 ? data direction port d bits 1 = associated pin is an output. 0 = associated pin is an input. 9.3.3 port d key wakeup interrupt enable register read: anytime write: anytime this register is not in the map in wide expanded modes and in special expanded narrow mode with mode register bit emd set. kwied7 ? kwied0 ? key wakeup port d interrupt enable bits 1 = interrupt for the associated bit is enabled. 0 = interrupt for the associated bit is disabled. address: $0007 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 9-2. port d data direction register (ddrd) address: $0020 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 9-3. port d key wakeup interrupt enable register (kwied)
MC68HC812A4 ? rev. 5.0 advance information 148 key wakeups motorola key wakeups 9.3.4 port d key wakeup flag register read: anytime write: anytime each flag is set by a falling edge on its associated input pin. to clear the flag, write 1 to the corresponding bit in kwifd. this register is not in the map in wide expanded modes or in special expanded narrow mode with mode register bit emd set. kwifd7 ? kwifd0 ? key wakeup port d flags 1 = falling edge on the associated bit has occurred. an interrupt occurs if the associated enable bit is set. 0 = falling edge on the associated bit has not occurred. 9.3.5 port h data register read: anytime write: anytime port h is associated with key wakeup h. key wakeups can be used with the pins designated as inputs or outputs. ddrh determines whether each pin is an input or output. address: $0021 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 9-4. port d key wakeup flag register (kwifd) address: $0024 bit 7654321bit 0 read: ph7 ph6 ph5 ph4 ph3 ph2 ph1 ph0 write: reset:00000000 alternate pin function: kwh7 kwh6 kwh5 kwh4 kwh3 kwh2 kwh1 kwh0 figure 9-5. port h data register (porth)
key wakeups key wakeup registers advance information MC68HC812A4 ? rev. 5.0 motorola key wakeups 149 9.3.6 port h data direction register read: anytime write: anytime data direction register h is associated with port h and designates each pin as an input or output. ddrh7 ? ddrh0 ? data direction port h bits 1 = associated pin is an output. 0 = associated pin is an input. 9.3.7 port h key wakeup interrupt enable register an interrupt is generated when a bit in the kwifh register and its corresponding kwieh bit are both set. these bits correspond to the pins of port h. kwieh7 ? kwieh0 ? key wakeup port h interrupt enable bits 1 = interrupt for the associated bit is enabled. 0 = interrupt for the associated bit is disabled. address: $0025 bit 7654321bit 0 read: ddrh7 ddrh6 ddrh5 ddrh4 ddrh3 ddrh2 ddrh1 ddrh0 write: reset:00000000 figure 9-6. port h data direction register (ddrh) address: $0026 bit 7654321bit 0 read: kwieh7 kwieh6 kwieh5 kwieh4 kwieh3 kwieh2 kwieh1 kwieh0 write: reset:00000000 figure 9-7. port h key wakeup interrupt enable register (kwieh)
MC68HC812A4 ? rev. 5.0 advance information 150 key wakeups motorola key wakeups 9.3.8 port h key wakeup flag register read: anytime write: anytime each flag is set by a falling edge on its associated input pin. to clear the flag, write one to the corresponding bit in kwifh. kwifh7 ? kwifh0 ? key wakeup port h flags 1 = falling edge on the associated bit has occurred (an interrupt occurs if the associated enable bit is set) 0 = falling edge on the associated bit has not occurred 9.3.9 port j data register read: anytime write: anytime port j is associated with key wakeup j. key wakeups can be used with the pins designated as inputs or outputs. ddrj determines whether each pin is an input or output. address: $0027 bit 7654321bit 0 read: kwifh7 kwifh6 kwifh5 kwifh4 kwifh3 kwifh2 kwifh1 kwifh0 write: reset:00000000 figure 9-8. port h key wakeup flag register (kwifh) address: $0028 bit 7654321bit 0 read: pj7 pj6 pj5 pj4 pj3 pj2 pj1 pj0 write: reset:00000000 alternate pin function: kwj7 kwj6 kwj5 kwj2 kwj4 kwj2 kwj1 kwj0 figure 9-9. port j data register (portj)
key wakeups key wakeup registers advance information MC68HC812A4 ? rev. 5.0 motorola key wakeups 151 9.3.10 port j data direction register determines direction of each port j pin. ddrj7 ? ddrj0 ? data direction port j bits 1 = associated pin is an output. 0 = associated pin is an input. 9.3.11 port j key wakeup interrupt enable register read: anytime write: anytime an interrupt is generated when a bit in the kwifj register and its corresponding kwiej bit are both set. these bits correspond to the pins of port j. all eight bits/pins share the same interrupt vector. kwiej7 ? kwief0 ? key wakeup port j interrupt enable bits 1 = interrupt for the associated bit is enabled. 0 = interrupt for the associated bit is disabled. address: $0029 bit 7654321bit 0 read: ddrj7 ddrj6 ddrj5 ddrj4 ddrj3 ddrj2 ddrj1 ddrj0 write: reset:00000000 figure 9-10. port j data direction register (ddrj) address: $002a bit 7654321bit 0 read: kwiej7 kwiej6 kwiej5 kwiej4 kwiej3 kwiej2 kwiej1 kwiej0 write: reset:00000000 figure 9-11. port j key wakeup interrupt enable register (kwiej)
MC68HC812A4 ? rev. 5.0 advance information 152 key wakeups motorola key wakeups 9.3.12 port j key wakeup flag register read: anytime write: anytime each flag gets set by an active edge on the associated input pin. this could be a rising or falling edge based on the state of the kpolj register. to clear the flag, write 1 to the corresponding bit in kwifj. initialize this register after initializing kpolj so that illegal flags can be cleared. kwifj7 ? kwifj0 ? key wakeup port j flags 1 = an active edge on the associated bit has occurred. an interrupt occurs if the associated enable bit is set. 0 = an active edge on the associated bit has not occurred. 9.3.13 port j key wakeup polarity register read: anytime write: anytime address: $002b bit 7654321bit 0 read: kwifj7 kwifj6 kwifj5 kwifj4 kwifj3 kwifj2 kwifj1 kwifj0 write: reset:00000000 figure 9-12. port j key wakeup flag register (kwifj) address: $002c bit 7654321bit 0 read: kpolj7 kpolj6 kpolj5 kpolj4 kpolj3 kpolj2 kpolj1 kpolj0 write: reset:00000000 figure 9-13. port j key wakeup polarity register (kpolj)
key wakeups key wakeup registers advance information MC68HC812A4 ? rev. 5.0 motorola key wakeups 153 it is best to clear the flags after initializing this register because changing the polarity of a bit can cause the associated flag to set. kpolj7 ? kpolj0 ? key wakeup port j polarity select bits 1 = rising edge on the associated port j pin sets the associated flag bit in the kwifj register. 0 = falling edge on the associated port j pin sets the associated flag bit in the kwifj register. 9.3.14 port j pullup/pulldown select register read: anytime write: anytime each bit in the register corresponds to a port j pin. each bit selects a pullup or pulldown device for the associated port j pin. the pullup or pulldown is active only if enabled by the pulej register. pupsj should be initialized before enabling the pullups/pulldowns (pupej). pupsj7 ? pupsj0 ? key wakeup port j pullup/pulldown select bits 1 = pullup is selected for the associated port j pin. 0 = pulldown is selected for the associated port j pin. address: $002d bit 7654321bit 0 read: pupsj7 pupsj6 pupsj5 pupsj4 pupsj3 pupsj2 pupsj1 pupsj0 write: reset:00000000 figure 9-14. port j pullup/pulldown select register (pupsj)
MC68HC812A4 ? rev. 5.0 advance information 154 key wakeups motorola key wakeups 9.3.15 port j pullup/pulldown enable register read: anytime write: anytime each bit in the register corresponds to a port j pin. if a pin is configured as an input, each bit enables an active pullup or pulldown device. pupsj selects whether a pullup or a pulldown is the active device. pulej7 ? pulej0 ? key wakeup port j pullup/pulldown enable bits 1 = selected pullup/pulldown device for the associated port j pin is enabled if it is an input. 0 = associated port j pin has no pullup/pulldown device. address: $002e bit 7654321bit 0 read: pulej7 pulej6 pulej5 pulej4 pulej3 pulej2 pulej1 pulej0 write: reset:00000000 figure 9-15. port j pullup/pulldown enable register (pulej)
advance information MC68HC812A4 ? rev. 5.0 motorola clock module 155 advance information ? MC68HC812A4 section 10. clock module 10.1 contents 10.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .156 10.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .156 10.3.1 clock generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .157 10.4 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .158 10.5 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .158 10.5.1 computer operating properly (cop) . . . . . . . . . . . . . . . . .158 10.5.2 real-time interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .159 10.5.3 clock monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 10.5.4 peripheral clock divider chains. . . . . . . . . . . . . . . . . . . . . 160 10.6 registers and reset initialization . . . . . . . . . . . . . . . . . . . . . . 163 10.6.1 real-time interrupt control register . . . . . . . . . . . . . . . . .163 10.6.2 real-time interrupt flag register . . . . . . . . . . . . . . . . . . .165 10.6.3 cop control register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 10.6.4 arm/reset cop timer register . . . . . . . . . . . . . . . . . . . . .168
MC68HC812A4 ? rev. 5.0 advance information 156 clock module motorola clock module 10.2 introduction clock generation circuitry generates the internal and external e-clock signals as well as internal clock signals used by the cpu and on-chip peripherals. a clock monitor circuit, a computer operating properly (cop) watchdog circuit, and a periodic interrupt circuit are also incorporated into the mcu. 10.3 block diagram figure 10-1. clock module block diagram 0:1:1 extal xtal 0:0:0 0:0:1 0:1:0 1:0:0 1:0:1 1:1:0 1:1:1 sysclk eclk pclk mclk tclk 2 2 2 2 2 2 2 2 oscillator phase-lock loop plls to cpu t-clock generator e- and p-clock generator muxclk 0:0 0:1 1:0 2 2 2 register: clkctl bits: mcs[b:a] register: clkctl bits: bcs[c:b:a] to bdm, buses, spi, atd to sci, tim, pa, rti, cop 1:1 2
clock module block diagram advance information MC68HC812A4 ? rev. 5.0 motorola clock module 157 10.3.1 clock generators the clock module generates four types of internal clock signals derived from the oscillator: 1. t-clocks ? drives the cpu 2. e-clock ? drives the bus interfaces, bdm, spi, and atd 3. p-clock ? drives the bus interfaces, bdm, spi, and atd 4. m-clock ? drives on-chip modules such as the timer, sci, rti, cop, and restart-from-stop delay time figure 10-2 shows clock timing relationships. four bits in the clkctl register control the base clock and m-clock divide selection ( 1, 2, 4, and 8 are selectable). figure 10-2. internal clock relationships t1clk t2clk t3clk t4clk internal eclk pclk mclk note: the mclk depends on the chosen divider settings in the clkctl register. 8 mclk 4 mclk 2 mclk 1
MC68HC812A4 ? rev. 5.0 advance information 158 clock module motorola clock module 10.4 register map note: the register block can be mapped to any 2-kbyte boundary within the standard 64-kbyte address space. the register block occupies the first 512 bytes of the 2-kbyte block. this register map shows default addressing after reset. 10.5 functional description this section provides a functional description of the MC68HC812A4. 10.5.1 computer operating properly (cop) the cop or watchdog timer is an added check that a program is running and sequencing properly. when the cop is being used, software is responsible for keeping a free-running watchdog timer from timing out. if the watchdog timer times out, it is an indication that the software is no addr.register name bit 7654321bit 0 $0014 real-time interrupt control reg. (rtictl) see page 163. read: rtie rswai rsbck 0 rtbyp rtr2 rtr1 rtr0 write: reset:00000000 $0015 real-time interrupt flag register (rtiflg) see page 165. read: rtif 0000000 write: reset:00000000 $0016 cop control register (copctl) see page 165. read: cme fcme fcm fcop disr cr2 cr1 cr0 write: reset:00000000 special reset: 00001111 $0017 arm/reset cop register (coprst) see page 168. read: 00000000 write: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 reset:00000000 = unimplemented figure 10-3. clock function register map
clock module functional description advance information MC68HC812A4 ? rev. 5.0 motorola clock module 159 longer being executed in the intended sequence; thus, a system reset is initiated. three control bits allow selection of seven cop timeout periods. when cop is enabled, sometime during the selected period the program must write $55 and $aa (in this order) to the coprst register. if the program fails to do this, the part resets. if any value other than $55 or $aa is written, the part resets. 10.5.2 real-time interrupt there is a real-time (periodic) interrupt (rti) available to the user. this interrupt occurs at one of seven selected rates. an interrupt flag and an interrupt enable bit are associated with this function. the rate select has three bits. 10.5.3 clock monitor the clock monitor circuit is based on an internal resistor-capacitor (rc) time delay. if no mcu clock edges are detected within this rc time delay, the clock monitor can generate a system reset. the clock monitor function is enabled/disabled by the cme control bit in the copctl register. this timeout is based on an rc delay so that the clock monitor can operate without any mcu clocks. cme enables clock monitor. 1 = slow or stopped clocks (including the stop instruction) cause a clock reset sequence. 0 = clock monitor is disabled. slow clocks and stop instruction may be used. clock monitor timeouts are shown in table 10-1 . table 10-1. clock monitor timeouts supply range 5 v 10% 2 ? 20 s 3 v 10% 5 ? 100 s
MC68HC812A4 ? rev. 5.0 advance information 160 clock module motorola clock module 10.5.4 peripheral clock divider chains figure 10-4 , figure 10-5 , and figure 10-6 summarize the peripheral clock divider chains. figure 10-4. clock chain for sci0, sci1, rti, and cop 0:0:0 0:0:1 0:1:0 0:1:1 1:0:0 1:0:1 1:1:0 1:1:1 0:0:0 0:0:1 0:1:0 0:1:1 1:0:1 1:1:0 1:1:1 2 2 2 2 2 2 4 4 4 4 4 4 1:0:0 sci0 receive baud rate (16x) sci0 transmit baud rate (1x) sci0 baud rate generator ( 1 to 8191) register: rtictl bits: rtr[2:1:0] register: copctl bits: cr[2:1:0] 8192 16 sci1 receive baud rate (16x) sci1 transmit baud rate (1x) sci1 baud rate generator ( 1 to 8191) 16 mclk to rti to cop
clock module functional description advance information MC68HC812A4 ? rev. 5.0 motorola clock module 161 figure 10-5. clock chain for tim mclk port t7 paclk paclk (paov) ten 0:0:0 0:0:1 0:1:0 0:1:1 1:0:0 1:0:1 register: tmsk2 bits: pr[2:0] pamod 2 2 2 2 2 2 gate logic paen pulse accumulator low byte pulse accumulator high byte 1:0:0 1:0:1 1:1:0 1:1:1 register: pactl bits: paen:clk1:clk0 0:x:x to tim counter 65,536 paclk 256
MC68HC812A4 ? rev. 5.0 advance information 162 clock module motorola clock module figure 10-6. clock chain for spi, atd, and bdm pclk bkgd out bkgd 0:0:1 0:1:0 0:1:1 1:0:0 1:0:1 1:1:0 1:1:1 2 2 2 2 2 2 spi bit rate register: sp0br bits: spr2:spr1:spr0 0:0:0 bdm bit clock receive: detect falling edge; count 12 e-clocks; sample input transmit 1: detect falling edge; count six e-clocks while output is high impedance; drive out one e cycle pulse high; return output to high impedance transmit 0: detect falling edge; drive out low; count nine e-clocks; drive out one e cycle pulse high; return output to high-impedance prs[4:0] 5-bit atd prescaler 2 atd clock bkgd pin logic synchronizer 2 eclk direction bkgd in
clock module registers and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola clock module 163 10.6 registers and reset initialization this section describes the registers and reset initialization. 10.6.1 real-time interrupt control register read: anytime write: varies from bit to bit rtie ? real-time interrupt enable bit write: anytime rtie enables interrupt requests generated by the rtif flag. 1 = rtif interrupt requests enabled 0 = rtif interrupt requests disabled rswai ? rti stop in wait bit write: once in normal modes, anytime in special modes rswai disables the rti and the cop during wait mode. 1 = rti and cop disabled in wait mode 0 = rti and cop enabled in wait mode rsbck ? rti stop in background mode bit write: once in normal modes, anytime in special modes rsbck disables the rti and the cop during background debug mode. 1 = rti and cop disabled during background mode 0 = rti and cop enabled during background mode address: $0014 bit 7654321bit 0 read: rtie rswai rsbck 0 rtbyp rtr2 rtr1 rtr0 write: reset:00000000 = unimplemented figure 10-7. real-time interrupt control register (rtictl)
MC68HC812A4 ? rev. 5.0 advance information 164 clock module motorola clock module rtbyp ? rti bypass bit write: never in normal modes, anytime in special modes rtbyp allows faster testing by causing the divider chain to be bypassed. the divider chain normally divides m by 2 13 . when rtbyp is set, the divider chain divides m by 4. 1 = divider chain bypass 0 = no divider chain bypass rtr2, rtr1, rtr0 ? real-time interrupt rate select bits write: anytime rate select for real-time interrupt. the clock used for this module is the module (m) clock. table 10-2. real-time interrupt rates rtr[2:1:0] m-clock divisor real-time timeout period m = 4.0 mhz m = 8.0 mhz 000 off off off 001 2 13 2.048 ms 1.024 ms 010 2 14 4.096 ms 2.048 ms 011 2 15 8.196 ms 4.096 ms 100 2 16 16.384 ms 8.196 ms 101 2 17 32.768 ms 16.384 ms 110 2 18 65.536 ms 32.768 ms 111 2 19 131.72 ms 65.536 ms
clock module registers and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola clock module 165 10.6.2 real-time interrupt flag register rtif ? real-time interrupt flag rtif is set when the timeout period elapses. rtif generates an interrupt request if the rtie bit is set in the rti control register. clear rtif by writing to the real-time interrupt flag register with rtif set. 1 = timeout period elapsed 0 = timeout period not elapsed 10.6.3 cop control register read: anytime write: varies from bit to bit address: $0015 bit 7654321bit 0 read: rtif 0000000 write: reset:00000000 = unimplemented figure 10-8. real-time interrupt flag register (rtiflg) address: $0016 bit 7654321bit 0 read: cme fcme fcm fcop disr cr2 cr1 cr0 write: normal reset:00000000 special reset:00001111 figure 10-9. cop control register (copctl)
MC68HC812A4 ? rev. 5.0 advance information 166 clock module motorola clock module cme ? clock monitor enable bit write: anytime cme enables the clock monitor. if the force clock monitor enable bit, fcme, is set, cme has no meaning or effect. 1 = clock monitor enabled 0 = clock monitor disabled note: clear the cme bit before executing a stop instruction and set the cme bit after exiting stop mode. fcme ? force clock monitor enable bit write: once in normal modes, anytime in special modes fcme forces the clock monitor to be enabled until a reset occurs. when fcme is set, the cme bit has no effect. 1 = clock monitor enabled 0 = cme bit enables or disables clock monitor note: clear the fcme bit in applications that use the stop instruction and the clock monitor. fcm ? force clock monitor reset bit write: never in normal modes, anytime in special modes fcm forces a reset when the clock monitor is enabled and detects a slow or stopped clock. 1 = clock monitor reset enabled 0 = normal operation note: when the disable reset bit, disr, is set, fcm has no effect. fcop ? force cop reset bit write: never in normal modes; anytime in special modes fcop forces a reset when the cop is enabled and times out. 1 = cop reset enabled 0 = normal operation note: when the disable reset bit, disr, is set, fcop has no effect.
clock module registers and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola clock module 167 disr ? disable reset bit write: never in normal modes; anytime in special modes disr disables clock monitor resets and cop resets. 1 = clock monitor and cop resets disabled 0 = normal operation cr2, cr1, and cr0 ? cop watchdog timer rate select bits write: once in normal modes, anytime in special modes the cop system is driven by a constant frequency of m/2 13 . these bits specify an additional division factor to arrive at the cop timeout rate. (the clock used for this module is the m-clock.) table 10-3. cop watchdog rates cr[2:1:0] m-clock divisor cop timeout period 0/+2.048 ms 0/+1.024 ms m = 4.0 mhz m = 8.0 mhz 000 off off off 001 2 13 2.048 ms 1.024 ms 010 2 15 8.1920 ms 4.096 ms 011 2 17 32.768 ms 16.384 ms 100 2 19 131.072 ms 65.536 ms 101 2 21 524.288 ms 262.144 ms 110 2 22 1.048 s 524.288 ms 111 2 23 2.097 s 1.048576 s
MC68HC812A4 ? rev. 5.0 advance information 168 clock module motorola clock module 10.6.4 arm/reset cop timer register to restart the cop timeout period and avoid a cop reset, write $55 and then $aa to this address before the end of the cop timeout period. other instructions can be executed between these writes. writing anything other than $55 or $aa causes a cop reset to occur. address: $0017 bit 7654321bit 0 read: 0 0 000000 write:bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 reset:00000000 figure 10-10. arm/reset cop timer register (coprst)
advance information MC68HC812A4 ? rev. 5.0 motorola phase-lock loop (pll) 169 advance information ? MC68HC812A4 section 11. phase-lock loop (pll) 11.1 contents 11.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169 11.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .170 11.4 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .172 11.5 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .172 11.6 registers and reset initialization . . . . . . . . . . . . . . . . . . . . . . 173 11.6.1 loop divider registers . . . . . . . . . . . . . . . . . . . . . . . . . . . .173 11.6.2 reference divider registers . . . . . . . . . . . . . . . . . . . . . . .174 11.6.3 clock control register . . . . . . . . . . . . . . . . . . . . . . . . . . . .175 11.2 introduction the phase-lock loop (pll) allows slight adjustments in the frequency of the mcu. the smallest increment of adjustment is 9.6 khz to the output frequency (f out ) rate assuming an input clock of 16.8 mhz (oscxtal) and a reference divider set to 1750. figure 11-1 shows the pll dividers and a portion of the clock module and figure 11-2 provides a register map.
MC68HC812A4 ? rev. 5.0 advance information 170 phase-lock loop (pll) motorola phase-lock loop (pll) 11.3 block diagram figure 11-1. pll block diagram eclk & pclk generator mux ldv[11:0] module clock divider loop divider reference divider out-of-lock detector phase detector vco tclk generator base clock divider oscillator extal pin charge pump xfc pin v ddpll pllon plls f reference f loop up down lckf muxclk bcs[c:b:a] sysclk pclk eclk to mpu rdv[11:0] tclk to cpu mcs[b:a] to modules xtal pin mclk c s r s c p loop filter see table 11-1 2
phase-lock loop (pll) block diagram advance information MC68HC812A4 ? rev. 5.0 motorola phase-lock loop (pll) 171 table 11-1. pll filter values r s e clock c s crystal 16,778.40524 8,000,000 0.000000033 32,000 11,864.12412 8,000,000 0.000000033 64,000 3,001.412373 8,000,000 0.000000033 1,000,000 2,450.642941 8,000,000 0.000000033 1,500,000 2,237.120698 8,000,000 0.000000033 1,800,000 2,122.319042 8,000,000 0.000000033 2,000,000 1,898.259859 8,000,000 0.000000033 2,500,000 1,732.866242 8,000,000 0.000000033 3,000,000 1,604.322397 8,000,000 0.000000033 3,500,000 1,500.706187 8,000,000 0.000000033 4,000,000 1,355.8999 8,000,000 0.000000033 4,900,000 1,342.272419 8,000,000 0.000000033 5,000,000 c p = .0033 f
MC68HC812A4 ? rev. 5.0 advance information 172 phase-lock loop (pll) motorola phase-lock loop (pll) 11.4 register map 11.5 functional description the pll may be used to run the mcu from a different timebase than the incoming crystal value. if the pll is selected, it continues to run when it ? s in wait or stop mode which results in more power consumption than normal. to take full advantage of the reduced power consumption of stop mode, turn off the pll before going into stop. although it is possible to set the divider to command a very high clock frequency, do not exceed the 16.8 mhz frequency limit for the mcu. addr.register name bit 7654321bit 0 $0040 loop divider register high (ldvh) see page 173. read: 0000 ldv11 ldv10 ldv9 ldv8 write: reset:00001111 $0041 loop divider register low (ldvl) see page 173. read: ldv7 ldv6 ldv5 ldv4 ldv3 ldv2 ldv1 ldv0 write: reset:11111111 $0042 reference divider register high (rdvh) see page 174. read: 0000 rdv11 rdv10 rdv9 rdv8 write: reset:00001111 $0043 reference divider register low (rdvl) see page 174. read: rdv7 rdv6 rdv5 rdv4 rdv3 rdv2 rdv1 rdv0 write: reset:11111111 $0047 clock control register (clkctl) see page 175. read: lckf pllon plls bcsc bcsb bcsa mcsb mcsa write: reset:00000000 = unimplemented figure 11-2. pll register map
phase-lock loop (pll) registers and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola phase-lock loop (pll) 173 a passive external loop filter must be placed on the control line (xfc pad). the filter is a second-order, low-pass filter to eliminate the vco input ripple. 11.6 registers and reset initialization this section describes the registers and reset initialization. 11.6.1 loop divider registers read: anytime write: anytime if the pll is on, the count in the loop divider (ldv) 12-bit register effectively multiplies up from the pll base frequency. caution: do not exceed the maximum rated operating frequency for the cpu. address: $0040 bit 7654321bit 0 read: 0 0 0 0 ldv11 ldv10 ldv9 ldv8 write: reset:00001111 = unimplemented figure 11-3. loop divider register high (ldvh) address: $0041 bit 7654321bit 0 read: ldv7 ldv6 ldv5 ldv4 ldv3 ldv2 ldv1 ldv0 write: reset:11111111 figure 11-4. loop divider register low (ldvl)
MC68HC812A4 ? rev. 5.0 advance information 174 phase-lock loop (pll) motorola phase-lock loop (pll) 11.6.2 reference divider registers read: anytime write: anytime the count in the reference divider (rdv) 12-bit register divides the crystal oscillator clock input. in the reset condition, both ldv and rdv are set to the maximum count which produces an internal frequency at the phase detector of 8.2 khz and a final output frequency of 16.8 mhz with a 16.8 mhz input clock. address: $0042 bit 7654321bit 0 read: 0 0 0 0 rdv11 rdv10 rdv9 rdv8 write: reset:00001111 = unimplemented figure 11-5. reference divider register high (rdvh) address: $0043 bit 7654321bit 0 read: rdv7 rdv6 rdv5 rdv4 rdv3 rdv2 rdv1 rdv0 write: reset:11111111 figure 11-6. reference divider register low (rdvl)
phase-lock loop (pll) registers and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola phase-lock loop (pll) 175 11.6.3 clock control register read: anytime write: anytime lckf ? lock flag this read-only flag is set when the pll frequency is at least half the target frequency and no more than twice the target frequency. 1 = pll locked 0 = pll not locked pllon ? pll on bit setting pllon turns on the pll. 1 = pll on 0 = pll off plls ? pll select bit (pll output or crystal input frequency) plls selects the pll after the lckf flag is set. 1 = pll selected 0 = crystal input selected bcs[c:b:a] ? base clock select bits these bits determine the frequency of sysclk. sysclk is the source clock for the mcu, including the cpu and buses. see table 11-2 . sysclk and is twice the bus rate. muxclk is either the pll output or the crystal input frequency as selected by the plls bit. address: $0047 bit 7654321bit 0 read: lckf pllon plls bcsc bcsb bcsa mcsb mcsa write: reset:00000000 = unimplemented figure 11-7. clock control register (clkctl)
MC68HC812A4 ? rev. 5.0 advance information 176 phase-lock loop (pll) motorola phase-lock loop (pll) mcsa and mcsb ? module clock select bits these bits determine the clock used by some sections of some of the modules such as the baud rate generators of the scis, the timer counter, the rti, and cop. see table 11-3 . mclk is the module clock and pclk is an internal bus rate clock. the bcsx and mcsx bits can be changed with a single-write access. in combination, these bits can be used to ? throttle ? the cpu clock rate without affecting the mclk rate; timing and baud rates can remain constant as the processor speed is changed to match system requirements. this can save overall system power. table 11-2. base clock selection bcsc:bcsb:bcsa sysclk 000 muxclk 001 010 011 100 101 110 111 table 11-3. module clock selection mcs[b:a] mclk 00 pclk 01 10 11 muxclk 2 ------------------------ - muxclk 4 ------------------------ - muxclk 8 ------------------------ - muxclk 16 ------------------------ - muxclk 32 ------------------------ - muxclk 64 ------------------------ - muxclk 128 ------------------------ - pclk 2 -------------- - pclk 4 -------------- - pclk 8 -------------- -
advance information MC68HC812A4 ? rev. 5.0 motorola standard timer module 177 advance information ? MC68HC812A4 section 12. standard timer module 12.1 contents 12.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .178 12.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .179 12.4 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .180 12.5 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .184 12.5.1 prescaler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .184 12.5.2 input capture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .184 12.5.3 output compare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .185 12.5.4 pulse accumulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .186 12.5.4.1 event counter mode . . . . . . . . . . . . . . . . . . . . . . . . . . .187 12.5.4.2 gated time accumulation mode . . . . . . . . . . . . . . . . . .187 12.6 registers and reset initialization . . . . . . . . . . . . . . . . . . . . . . 188 12.6.1 timer ic/oc select register . . . . . . . . . . . . . . . . . . . . . . .188 12.6.2 timer compare force register . . . . . . . . . . . . . . . . . . . . .189 12.6.3 timer output compare 7 mask register . . . . . . . . . . . . . .189 12.6.4 timer output compare 7 data register. . . . . . . . . . . . . . .190 12.6.5 timer counter registers . . . . . . . . . . . . . . . . . . . . . . . . . .191 12.6.6 timer system control register . . . . . . . . . . . . . . . . . . . . .192 12.6.7 timer control registers 1 and 2 . . . . . . . . . . . . . . . . . . . .194 12.6.8 timer control registers 3 and 4 . . . . . . . . . . . . . . . . . . . .195 12.6.9 timer mask register 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . .196 12.6.10 timer mask register 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . .196 12.6.11 timer flag register 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .198 12.6.12 timer flag register 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .198 12.6.13 timer channel registers . . . . . . . . . . . . . . . . . . . . . . . . . .199 12.6.14 pulse accumulator control register . . . . . . . . . . . . . . . . . 200 12.6.15 pulse accumulator flag register . . . . . . . . . . . . . . . . . . . .202 12.6.16 pulse accumulator counter registers . . . . . . . . . . . . . . . .203 12.6.17 timer test register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .204
MC68HC812A4 ? rev. 5.0 advance information 178 standard timer module motorola standard timer module 12.7 external pins. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .205 12.7.1 input capture/output compare pins . . . . . . . . . . . . . . . . .205 12.7.2 pulse accumulator pin . . . . . . . . . . . . . . . . . . . . . . . . . . . .205 12.8 background debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . .206 12.9 low-power options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .206 12.9.1 run mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .206 12.9.2 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .206 12.9.3 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .207 12.10 interrupt sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .207 12.11 general-purpose i/o ports . . . . . . . . . . . . . . . . . . . . . . . . . . .207 12.11.1 timer port data register . . . . . . . . . . . . . . . . . . . . . . . . . .208 12.11.2 timer port data direction register . . . . . . . . . . . . . . . . . .209 12.12 using the output compare function to generate a square wave . . . . . . . . . . . . . . . . . . . . . . .210 12.12.1 sample calculation to obtain period counts . . . . . . . . . . .210 12.12.2 equipment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211 12.12.3 code listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211 12.2 introduction the standard timer module is a 16-bit, 8-channel timer with:  input capture  output compare  pulse accumulator functions a block diagram is given in figure 12-1 and a summary of the input/oputput (i/o) registers is shown in figure 12-2 .
standard timer module block diagram advance information MC68HC812A4 ? rev. 5.0 motorola standard timer module 179 12.3 block diagram figure 12-1. timer block diagram prescaler channel 0 pt0 16-bit counter module logic pr[2:1:0] divide-by-64 module clock timc0h:timc0l edge detect timpacnth:timpacntl paovf pedge paovi pamod pae 16-bit comparator timcnth:timcntl 16-bit latch channel 1 timc1h:timc1l 16-bit comparator 16-bit latch 16-bit counter interrupt logic tof toi c0f c1f edge detect pt1 logic edge detect cxf channels 2 ? 6 channel 7 timc7h:timc7l 16-bit comparator 16-bit latch c7f pt7 logic edge detect ios0 ios1 ios7 om0 ol0 om1 ol1 om7 ol7 edg1a edg1b edg7a edg7b edg0a edg0b tcre channel 7 output compare paif clear counter paif pai interrupt logic cxi interrupt request interrupt request paovf ch. 7 compare ch. 7 capture ch. 1 capture mux clk[1:0] paclk paclk/256 paclk/65536 pad pad pad paclk paclk/256 paclk/65536 te clock ch. 1 compare ch. 0 compare ch. 0 capture pa input
MC68HC812A4 ? rev. 5.0 advance information 180 standard timer module motorola standard timer module 12.4 register map note: the register block can be mapped to any 2-kbyte boundary within the standard 64-kbyte address space. the register block occupies the first 512 bytes of the 2-kbyte block. this register map shows default addressing after reset. addr.register name bit 7654321bit 0 $0080 timer ic/oc select register (tios) see page 188. read: ios7 ios6 ios5 ios4 ios3 ios2 ios1 ios0 write: reset:00000000 $0081 timer compare force register (cforc) see page 189. read: foc7 foc6 foc5 foc4 foc3 foc2 foc1 foc0 write: reset:00000000 $0082 timer output compare 7 mask register (oc7m) see page 189. read: oc7m7 oc7m6 oc7m5 oc7m4 oc7m3 oc7m2 oc7m1 oc7m0 write: reset:00000000 $0083 timer output compare 7 data register (oc7d) see page 190. read: oc7d7 oc7d6 oc7d5 oc7d4 oc7d3 oc7d2 oc7d1 oc7d0 write: reset:00000000 $0084 timer counter register high (tcnth) see page 191. read: bit 15 14 13 12 11 10 9 bit 8 write: reset:00000000 $0085 timer counter register low (tcntl) see page 191. read: bit 7 6 5 4 3 2 1 bit 0 write: reset:00000000 $0086 timer system control register (tscr) see page 192. read: ten tswai tsbck tffca 0000 write: reset:00000000 $0087 reserved r r r r r r r r = unimplemented r = reserved figure 12-2. i/o register summary (sheet 1 of 5)
standard timer module register map advance information MC68HC812A4 ? rev. 5.0 motorola standard timer module 181 $0088 timer control register 1 (tctl1) see page 194. read: om7ol7om6ol6om5ol5om4ol4 write: reset:00000000 $0089 timer control register 2 (tctl2) see page 194. read: om3ol3om2ol2om1ol1om0ol0 write: reset:00000000 $008a timer control register 3 (tctl3) see page 195. read: edg7b edg7a edg6b edg6a edg5b edg5a edg4b edg4a write: reset:00000000 $008b timer control register 4 (tctl4) see page 195. read: edg3b edg3a edg2b edg2a edg1b edg1a edg0b edg0a write: reset:00000000 $008c timer mask register 1 (tmsk1) see page 196. read: c7i c6i c5i c4i c3i c2i c1i c0i write: reset:00000000 $008d timer mask register 2 (tmsk2) see page 196. read: toi 0 pupt rdpt tcre pr2 pr1 pr0 write: reset:00110000 $008e timer flag register 1 (tflg1) see page 198. read: c7f c6f c5f c4f c3f c2f c1f c0f write: reset:00000000 $008f timer flag register 2 (tflg2) see page 198. read: tof 0000000 write: reset:00000000 $0090 timer channel 0 register high (tc0h) see page 199. read: bit 15 14 13 12 11 10 9 bit 8 write: reset:00000000 $0091 timer channel 0 register low (tc0l) see page 199. read: bit 7654321bit 0 write: reset:00000000 addr.register name bit 7654321bit 0 = unimplemented r = reserved figure 12-2. i/o register summary (sheet 2 of 5)
MC68HC812A4 ? rev. 5.0 advance information 182 standard timer module motorola standard timer module $0092 timer channel 1 register high (tc1h) see page 199. read: bit 15 14 13 12 11 10 9 bit 8 write: reset:00000000 $0093 timer channel 1 register low (tc1l) see page 199. read: bit 7654321bit 0 write: reset:00000000 $0094 timer channel 2 register high (tc2h) see page 199. read: bit 15 14 13 12 11 10 9 bit 8 write: reset:00000000 $0095 timer channel 2 register low (tc2l) see page 199. read: bit 7654321bit 0 write: reset:00000000 $0096 timer channel 3 register high (tc3h) see page 199. read: bit 15 14 13 12 11 10 9 bit 8 write: reset:00000000 $0097 timer channel 3 register low (tc3l) see page 199. read: bit 7654321bit 0 write: reset:00000000 $0098 timer channel 4 register high (tc4h) see page 199. read: bit 15 14 13 12 11 10 9 bit 8 write: reset:00000000 $0099 timer channel 4 register low (tc4l) see page 199. read: bit 7654321bit 0 write: reset:00000000 $009a timer channel 5 register high (tc5h) see page 199. read: bit 15 14 13 12 11 10 9 bit 8 write: reset:00000000 $009b timer channel 5 register low (tc5l) see page 199. read: bit 7654321bit 0 write: reset:00000000 addr.register name bit 7654321bit 0 = unimplemented r = reserved figure 12-2. i/o register summary (sheet 3 of 5)
standard timer module register map advance information MC68HC812A4 ? rev. 5.0 motorola standard timer module 183 $009c timer channel 6 register high (tc6h) see page 199. read: bit 15 14 13 12 11 10 9 bit 8 write: reset:00000000 $009d timer channel 6 register low (tc6l) see page 199. read: bit 7654321bit 0 write: reset:00000000 $009e timer channel 7 register high (tc7h) see page 199. read: bit 15 14 13 12 11 10 9 bit 8 write: reset:00000000 $009f timer channel 7 register low (tc7l) see page 199. read: bit 76543210 write: reset:00000000 $00a0 pulse accumulator control register (pactl) see page 200. read: 0 paen pamod pedge clk1 clk0 paovi pai write: reset:00000000 $00a1 pulse accumulator flag register (paflg) see page 202. read: 000000 paovf paif write: reset:00000000 $00a2 pulse accumulator counter register high (pacnth) see page 203. read: bit 15 14 13 12 11 10 9 bit 8 write: reset:00000000 $00a3 pulse accumulator counter register low (pacntl) see page 203. read: bit 7654321bit 0 write: reset:00000000 $00ad timer test register (timtst) see page 204. read: 000000tcbyppcbyp write: reset:00000000 addr.register name bit 7654321bit 0 = unimplemented r = reserved figure 12-2. i/o register summary (sheet 4 of 5)
MC68HC812A4 ? rev. 5.0 advance information 184 standard timer module motorola standard timer module note: in normal modes, writing to a reserved bit has no effect and reading returns logic 0. in any mode, writing to an unimplemented bit has no effect and reading returns a logic 0. 12.5 functional description this section provides a functional description of the standard timer. 12.5.1 prescaler the prescaler divides the module clock by 1, 2, 4, 8, 16, 32, 64, or 128. the prescaler select bits, pr2, pr1, and pr0, select the prescaler divisor. pr2, pr1, and pr0 are in timer system control register 2 (timscr2). 12.5.2 input capture clearing the i/o (input/output) select bit, iosx, configures channel x as an input capture channel. the input capture function captures the time at which an external event occurs. when an active edge occurs on the pin of an input capture channel, the timer transfers the value in the timer counter into the timer channel registers, timcxh and timcxl. $00ae timer port data register (portt) see page 208. read: pt7pt6pt5pt4pt3pt2pt1pt0 write: reset: unaffected by reset $00af timer port data direction register (ddrt) see page 209. read: bit 7554321bit 0 write: reset:00000000 addr.register name bit 7654321bit 0 = unimplemented r = reserved figure 12-2. i/o register summary (sheet 5 of 5)
standard timer module functional description advance information MC68HC812A4 ? rev. 5.0 motorola standard timer module 185 in 8-bit mcus, the low byte of the timer channel register (timcxl) is held for one bus cycle after the high byte (timcxh) is read. this allows coherent reading of the timer channel such that an input capture does not occur between two back-to-back 8-bit reads. to read the 16-bit timer channel register, use a double-byte read instruction such as ldd or ldx. the minimum pulse width for the input capture input is greater than two module clocks. the input capture function does not force data direction. the timer port data direction register controls the data direction of an input capture pin. pin conditions can trigger an input capture on a pin configured as an input. software can trigger an input capture on an input capture pin configured as an output. an input capture on channel x sets the cxf flag. the cxi bit enables the cxf flag to generate interrupt requests. 12.5.3 output compare setting the i/o select bit, iosx, configures channel x as an output compare channel. the output compare function can generate a periodic pulse with a programmable polarity, duration, and frequency. when the timer counter reaches the value in the channel registers of an output compare channel, the timer can set, clear, or toggle the channel pin. an output compare on channel x sets the cxf flag. the cxi bit enables the cxf flag to generate interrupt requests. the output mode and level bits, omx and olx, select set, clear, or toggle on output compare. clearing both omx and olx disconnects the pin from the output logic. setting a force output compare bit, focx, causes an immediate output compare on channel x. a forced output compare does not set the channel flag.
MC68HC812A4 ? rev. 5.0 advance information 186 standard timer module motorola standard timer module an output compare on channel 7 overrides output compares on all other output compare channels. a channel 7 output compare causes any unmasked bits in the output compare 7 data register to transfer to the timer port data register. the output compare 7 mask register masks the bits in the output compare 7 data register. the timer counter reset enable bit, tcre, enables channel 7 output compares to reset the timer counter. a channel 7 output compare can reset the timer counter even if the oc7/pai pin is being used as the pulse accumulator input. an output compare overrides the data direction bit of the output compare pin but does not change the state of the data direction bit. writing to the timer port bit of an output compare pin does not affect the pin state. the value written is stored in an internal latch. when the pin becomes available for general-purpose output, the last value written to the bit appears at the pin. 12.5.4 pulse accumulator the pulse accumulator (pa) is a 16-bit counter that can operate in two modes:  event counter mode ? counting edges of selected polarity on the pulse accumulator input pin, pai  gated time accumulation mode ? counting pulses from a divide-by-64 clock the pa mode bit, pamod, selects the mode of operation. the minimum pulse width for the pai input is greater than two module clocks.
standard timer module functional description advance information MC68HC812A4 ? rev. 5.0 motorola standard timer module 187 12.5.4.1 event counter mode clearing the pamod bit configures the pa for event counter operation. an active edge on the pai pin increments the pa. the pa edge bit, pedge, selects falling edges or rising edges to increment the pa. an active edge on the pai pin sets the pa input flag, paif. the pa input interrupt enable bit, pai, enables the paif flag to generate interrupt requests. note: the pai input and timer channel 7 use the same pin. to use the pai input, disconnect it from the output logic by clearing the channel 7 output mode and output level bits, om7 and ol7. also clear the channel 7 output compare 7 mask bit, oc7m7. the pa counter registers, timpacnth/l, reflect the number of active input edges on the pai pin since the last reset. the pa overflow flag, paovf, is set when the pa rolls over from $ffff to $0000. the pa overflow interrupt enable bit, paovi, enables the paovf flag to generate interrupt requests. note: the pa can operate in event counter mode even when the timer enable bit, te, is clear. 12.5.4.2 gated time accumulation mode setting the pamod bit configures the pa for gated time accumulation operation. an active level on the pai pin enables a divided-by-64 clock to drive the pa. the pa edge bit, pedge, selects low levels or high levels to enable the divided-by-64 clock. the trailing edge of the active level at the pai pin sets the pa input flag, paif. the pa input interrupt enable bit, pai, enables the paif flag to generate interrupt requests. note: the pai input and timer channel 7 use the same pin. to use the pai input, disconnect it from the output logic by clearing the channel 7 output mode and output level bits, om7 and ol7. also clear the channel 7 output compare mask bit, oc7m7.
MC68HC812A4 ? rev. 5.0 advance information 188 standard timer module motorola standard timer module the pa counter registers, timpacnth/l reflect the number of pulses from the divided-by-64 clock since the last reset. note: the timer prescaler generates the divided-by-64 clock. if the timer is not active, there is no divided-by-64 clock. figure 12-3. channel 7 output compare/pulse accumulator logic 12.6 registers and reset initialization this section describes the registers and reset initialization. 12.6.1 timer ic/oc select register read: anytime write: anytime ios7 ? ios0 ? input capture or output compare select bits the iosx bits enable input capture or output compare operation for the corresponding timer channel. 1 = output compare enabled 0 = input capture enabled pad om7 ol7 channel 7 output compare pulse accumulator oc7m7 address: $0080 bit 7654321bit 0 read: ios7 ios6 ios5 ios4 ios3 ios2 ios1 ios0 write: reset:00000000 figure 12-4. timer ic/oc select register (tios)
standard timer module registers and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola standard timer module 189 12.6.2 timer compare force register read: anytime; always read $00 (1 state is transient) write: anytime foc7 ? foc0 ? force output compare bits setting an focx bit causes an immediate output compare on the corresponding channel. forcing an output compare does not set the output compare flag. 1 = force output compare 0 = no effect 12.6.3 timer output compare 7 mask register read: anytime write: anytime oc7m7 ? oc7m0 ? output compare 7 mask bits setting an oc7mx bit configures the corresponding timport pin to be an output. oc7mx makes the timer port pin an output regardless of the data direction bit when the pin is configured for output compare (iosx = 1). the oc7mx bits do not change the state of the timddr bits. 1 = corresponding timport pin output 0 = corresponding timport pin input address: $0081 bit 7654321bit 0 read: foc7 foc6 foc5 foc4 foc3 foc2 foc1 foc0 write: reset:00000000 figure 12-5. timer compare force register (cforc) address: $0082 bit 7654321bit 0 read: oc7m7 oc7m6 oc7m5 oc7m4 oc7m3 oc7m2 oc7m1 oc7m0 write: reset:00000000 figure 12-6. timer output compare 7 mask register (oc7m)
MC68HC812A4 ? rev. 5.0 advance information 190 standard timer module motorola standard timer module 12.6.4 timer output compare 7 data register read: anytime write: anytime oc7d7 ? oc7d0 ? output compare data bits when a successful channel 7 output compare occurs, these bits transfer to the timer port data register if the corresponding oc7mx bits are set. note: a successful channel 7 output compare overrides any channel 0 ? 6 compares. for each oc7m bit that is set, the output compare action reflects the corresponding oc7d bit. address: $0083 bit 7654321bit 0 read: oc7d7 oc7d6 oc7d5 oc7d4 oc7d3 oc7d2 oc7d1 oc7d0 write: reset:00000000 figure 12-7. timer output compare 7 data register (oc7d)
standard timer module registers and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola standard timer module 191 12.6.5 timer counter registers read: anytime write: only in special modes; has no effect in normal modes use a double-byte read instruction to read the timer counter. two single-byte reads return a different value than a double-byte read. note: the period of the first count after a write to the tcnt registers may be a different size because the write is not synchronized with the prescaler clock. address: $0084 bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 = unimplemented figure 12-8. timer counter register high (tcnth) address: $0085 bit 7654321bit 0 read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset:00000000 = unimplemented figure 12-9. timer counter register low (tcntl)
MC68HC812A4 ? rev. 5.0 advance information 192 standard timer module motorola standard timer module 12.6.6 timer system control register read: anytime write: anytime ten ? timer enable bit ten enables the timer. clearing ten reduces power consumption. 1 = timer enabled 0 = timer and timer counter disabled when the timer is disabled, there is no divided-by-64 clock for the pa since the prescaler generates the m 64 clock. tswai ? timer stop in wait mode bit tswai disables the timer and pa in wait mode. 1 = timer and pa disabled in wait mode 0 = timer and pa enabled in wait mode note: if timer and pa interrupt requests are needed to bring the mcu out of wait mode, clear tswai before executing the wait instruction. tsbck ? timer stop in background mode bit tsbck stops the timer during background mode. 1 = timer disabled in background mode 0 = timer enabled in background mode note: setting tsbck does not stop the pa when it is in event counter mode. address: $0086 bit 7654321bit 0 read: ten tswai tsbck tffca 0000 write: reset:00000000 = unimplemented figure 12-10. timer system control register (tscr)
standard timer module registers and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola standard timer module 193 tffca ? timer fast flag clear-all bit when tffca is set: ? an input capture read or a write to an output compare channel clears the corresponding channel flag, cnf. ? any access of the timer counter registers, tcnth/l, clears the tof flag. ? any access of the pa counter registers, pacnth/l, clears both the paovf and paif flags in the paflg register. when tffca is clear, writing logic 1s to the flags clears them. 1 = fast flag clearing 0 = normal flag clearing figure 12-11. fast clear flag logic clear write tcx registers read tcx registers tffca data bit n write tflg1 register cnf cnf flag
MC68HC812A4 ? rev. 5.0 advance information 194 standard timer module motorola standard timer module 12.6.7 timer control registers 1 and 2 read: anytime write: anytime omx/olx ? output mode/output level bits these bit pairs select the output action to be taken as a result of a successful output compare. when either omx or olx is set and the iosx bit is set, the pin is an output regardless of the state of the corresponding ddrt bit. channel 7 shares a pin with the pulse accumulator input pin. to use the pai input, clear both the om7 and ol7 bits and clear the oc7m7 bit in the output compare 7 mask register. address: $0088 bit 7654321bit 0 read: om7 ol7 om6 ol6 om5 ol5 om4 ol4 write: reset:00000000 figure 12-12. timer control register 1 (tctl1) address: $0089 bit 7654321bit 0 read: om3 ol3 om2 ol2 om1 ol1 om0 ol0 write: reset:00000000 figure 12-13. timer control register 2 (tctl2) table 12-1. selection of output compare action omx:olx action on output compare 00 timer disconnected from output pin logic 01 toggle ocn output line 10 clear ocn output line 11 set ocn output line
standard timer module registers and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola standard timer module 195 12.6.8 timer control registers 3 and 4 read: anytime write: anytime edgnb, edgna ? input capture edge control bits these eight bit pairs configure the input capture edge detector circuits. address: $008a bit 7654321bit 0 read: edg7b edg7a edg6b edg6a edg5b edg5a edg4b edg4a write: reset:00000000 figure 12-14. timer control register 3 (tctl3) address: $008b bit 7654321bit 0 read: edg3b edg3a edg2b edg2a edg1b edg1a edg0b edg0a write: reset:00000000 figure 12-15. timer control register 4 (tctl4) table 12-2. input capture edge selection edgnb:edgna edge selection 00 input capture disabled 01 input capture on rising edges only 10 input capture on falling edges only 11 input capture on any edge (rising or falling)
MC68HC812A4 ? rev. 5.0 advance information 196 standard timer module motorola standard timer module 12.6.9 timer mask register 1 read: anytime write: anytime c7i ? c0i ? channel interrupt enable bits these bits enable the flags in timer flag register 1. 1 = corresponding channel interrupt requests enabled 0 = corresponding channel interrupt requests disabled 12.6.10 timer mask register 2 read: anytime write: anytime toi ? timer overflow interrupt enable bit toi enables interrupt requests generated by the tof flag. 1 = tof interrupt requests enabled 0 = tof interrupt requests disabled address: $008c bit 7654321bit 0 read: c7i c6i c5i c4i c3i c2i c1i c0i write: reset:00000000 figure 12-16. timer mask 1 register (tmsk1) address: $008d bit 7654321bit 0 read: toi 0 pupt rdpt tcre pr2 pr1 pr0 write: reset:00110000 = unimplemented figure 12-17. timer mask 2 register (tmsk2)
standard timer module registers and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola standard timer module 197 pupt ? port t pullup enable bit pupt enables pullup resistors on the timer port pins when the pins are configured as inputs. 1 = pullup resistors enabled 0 = pullup resistors disabled rdpt ? port t reduced drive bit rdpt reduces the output driver size for lower current and less noise. 1 = output drive reduction enabled 0 = output drive reduction disabled tcre ? timer counter reset enable bit tcre allows the counter to be reset by a channel 7 output compare. 1 = counter reset enabled 0 = counter reset disabled note: when the timer channel 7 registers contain $0000 and tcre is set, the timer counter registers remain at $0000 all the time. when the timer channel 7 registers contain $ffff and tcre is set, tof never gets set even though the timer counter registers go from $ffff to $0000. pr2, pr1, and pr0 ? timer prescaler select bits these bits select the prescaler divisor for the timer counter. note: the newly selected prescale divisor does not take effect until the next synchronized edge when all prescale counter stages equal 0. table 12-3. prescaler selection value pr[2:1:0] prescaler divisor 0 000 1 1 001 2 2 010 4 3011 8 4 100 16 5 101 32 6110 32 7 111 32
MC68HC812A4 ? rev. 5.0 advance information 198 standard timer module motorola standard timer module 12.6.11 timer flag register 1 read: anytime write: anytime; writing 1 clears flag; writing 0 has no effect c7f ? c0f ? channel flags these flags are set when an input capture or output compare occurs on the corresponding channel. clear a channel flag by writing a 1 to it. note: when the fast flag clear-all bit, tffca, is set, an input capture read or an output compare write clears the corresponding channel flag. tffca is in the timer system control register (tscr). 12.6.12 timer flag register 2 read: anytime write: anytime; writing 1 clears flag; writing 0 has no effect address: $008e bit 7654321bit 0 read: c7f c6f c5f c4f c3f c2f c1f c0f write: reset:00000000 figure 12-18. timer flag register 1 (tflg1) address: $008f bit 7654321bit 0 read: tof 0000000 write: reset:00000000 = unimplemented figure 12-19. timer flag register 2 (tflg2)
standard timer module registers and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola standard timer module 199 tof ? timer overflow flag tof is set when the timer counter rolls over from $ffff to $0000. clear tof by writing a 1 to it. 1 = timer overflow 0 = no timer overflow note: when the timer channel 7 registers contain $ffff and the timer counter reset enable bit, tcre, is set, tof does not get set when the counter rolls over. note: when the fast flag clear-all bit, tffca, is set, any access to the timer counter registers clears tof. 12.6.13 timer channel registers address: tc0h/l: $0090/$0091 tc1h/l: $0092/$0093 tc2h/l: $0094/$0095 tc3h/l: $0096/$0097 tc4h/l: $0098/$0099 tc5h/l: $009a/$009b tc6h/l: $009c/$009d tc7h/l: $009e/$009f bit 7654321bit 0 read: bit 15 14 13 12 11 10 9 8 write: reset:00000000 bit 7654321bit 0 read: bit 7654321bit 0 write: reset:00000000 figure 12-20. timer channel registers (tcxh/l)
MC68HC812A4 ? rev. 5.0 advance information 200 standard timer module motorola standard timer module read: anytime write: output compare channel, anytime; input capture channel, no effect when a channel is configured for input capture (iosx = 0), the timer channel registers latch the value of the free-running counter when a defined transition occurs on the corresponding input capture pin. when a channel is configured for output compare (iosx = 1), the timer channel registers contain the output compare value. 12.6.14 pulse accumulator control register read: anytime write: anytime paen ? pulse accumulator enable bit paen enables the pulse accumulator. 1 = pulse accumulator enabled 0 = pulse accumulator disabled note: the pulse accumulator can operate even when the timer enable bit, ten, is clear. pamod ? pulse accumulator mode bit pamod selects event counter mode or gated time accumulation mode. 1 = gated time accumulation mode 0 = event counter mode address: $00a0 bit 7654321bit 0 read: 0 paen pamod pedge clk1 clk0 paovi pai write: reset:00000000 = unimplemented figure 12-21. pulse accumulator control register (pactl)
standard timer module registers and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola standard timer module 201 pedge ? pulse accumulator edge bit pedge selects falling or rising edges on the pai pin to increment the counter. in event counter mode (pamod = 0): 1 = rising pai edge increments counter 0 = falling pai edge increments counter in gated time accumulation mode (pamod = 1): 1 = low pai input enables divided-by-64 clock to pulse accumulator and trailing rising edge on pai sets paif flag 0 = high pai input enables divided-by-64 clock to pulse accumulator and trailing falling edge on pai sets paif flag note: the timer prescaler generates the divided-by-64 clock. if the timer is not active, there is no divided-by-64 clock. to operate in gated time accumulation mode: 1. apply logic 0 to the reset pin. 2. initialize registers for pulse accumulator mode test. 3. apply appropriate level on pai pin. 4. enable the timer. clk1 and clk0 ? clock select bits clk1 and clk0 select the timer counter input clock as shown in table 12-4 . table 12-4. clock selection clk[1:0] timer counter clock (1) 1. changing the clkx bits causes an immediate change in the timer counter clock input. 00 timer prescaler clock (2) 2. when pae = 0, the timer prescaler clock is always the timer counter clock. 01 paclk 10 11 paclk 256 ------------------- paclk 65,536 -------------------
MC68HC812A4 ? rev. 5.0 advance information 202 standard timer module motorola standard timer module paovi ? pulse accumulator overflow interrupt enable bit paovi enables the pulse accumulator overflow flag, paovf, to generate interrupt requests. 1 = paovf interrupt requests enabled 0 = paovf interrupt requests disabled pai ? pulse accumulator interrupt enable bit pai enables the pulse accumulator input flag, paif, to generate interrupt requests. 1 = paif interrupt requests enabled 0 = paif interrupt requests disabled 12.6.15 pulse accumulator flag register read: anytime write: anytime; writing 1 clears the flag; writing 0 has no effect paovf ? pulse accumulator overflow flag paovf is set when the 16-bit pulse accumulator overflows from $ffff to $0000. clear paovf by writing to the pulse accumulator flag register with paovf set. 1 = pulse accumulator overflow 0 = no pulse accumulator overflow address: $00a1 bit 7654321bit 0 read: 0 0 0000 paovf paif write: reset:00000000 = unimplemented figure 12-22. pulse accumulator flag register (paflg)
standard timer module registers and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola standard timer module 203 paif ? pulse accumulator input flag paif is set when the selected edge is detected at the pai pin. in event counter mode, the event edge sets paif. in gated time accumulation mode, the trailing edge of the gate signal at the pai pin sets paif. clear paif by writing to the pulse accumulator flag register with paif set. 1 = active pai input 0 = no active pai input note: when the fast flag clear-all enable bit, tffca, is set, any access to the pulse accumulator counter registers clears all the flags in the paflg register. 12.6.16 pulse accumulator counter registers read: anytime write: anytime these registers contain the number of active input edges on the pai pin since the last reset. address: $00a2 bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 address: $00a3 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 12-23. pulse accumulator counter registers (pacnth/l)
MC68HC812A4 ? rev. 5.0 advance information 204 standard timer module motorola standard timer module use a double-byte read instruction to read the pulse accumulator counter. two single-byte reads return a different value than a double-byte read. note: reading the pulse accumulator counter registers immediately after an active edge on the pai pin may miss the last count since the input has to be synchronized with the bus clock first. 12.6.17 timer test register read: anytime write: only in special mode (smodn = 0) tcbyp ? timer divider chain bypass bit tcbyp divides the 16-bit free-running timer counter into two 8-bit halves. the clock drives both halves directly and bypasses the timer prescaler. 1 = timer counter divided in half and prescaler bypassed 0 = normal operation pcbyp ? pulse accumulator divider chain bypass bit pcbyp divides the 16-bit pa counter into two 8-bit halves. the clock drives both halves directly and bypasses the timer prescaler. 1 = pa counter divided in half and prescaler bypassed 0 = normal operation address: $00ad bit 7654321bit 0 read: 0 0 0000tcbyppcbyp write: reset:00000000 = unimplemented figure 12-24. timer test register (timtst)
standard timer module external pins advance information MC68HC812A4 ? rev. 5.0 motorola standard timer module 205 12.7 external pins the timer has eight pins for input capture and output compare functions. one of the pins is also the pulse accumulator input. all eight pins are available for general-purpose i/o when not configured for timer functions. 12.7.1 input capture/output compare pins the iosx bits in the timer ic/oc select register configure the timer port pins as either output compare or input capture pins. the timer port data direction register controls the data direction of an input capture pin. external pin conditions trigger input captures on input capture pins configured as inputs. software triggers input captures on input capture pins configured as outputs. the timer port data direction register does not affect the data direction of an output compare pin. the output compare function overrides the data direction register but does not affect the state of the data direction register. 12.7.2 pulse accumulator pin setting the pae bit in the pulse accumulator control register enables the pulse accumulator input pin, pai. note: the pai input and timer channel 7 use the same pin. to use the pai input, disconnect it from the output logic by clearing the channel 7 output mode and output level bits, om7 and ol7. also clear the channel 7 output compare mask bit, oc7m7.
MC68HC812A4 ? rev. 5.0 advance information 206 standard timer module motorola standard timer module 12.8 background debug mode if the tsbck bit is clear, background debug mode has no effect on the timer. if tsbck is set, background debug mode disables the timer. note: setting tsbck does not stop the pulse accumulator when it is in event counter mode. 12.9 low-power options this section describes the three low-power modes:  run mode  wait mode  stop mode 12.9.1 run mode clearing the timer enable bit (ten) or the pulse accumulator enable bit (paen) reduces power consumption in run mode. ten is in the timer system control register (tscr). paen is in the pulse accumulator control register (pactl). timer and pulse accumulator registers are still accessible, but clocks to the core of the timer are disabled. 12.9.2 wait mode timer and pulse accumulator operation in wait mode depend on the state of the tswai bit in the timer system control register tscr).  if tswai is clear, the timer and pulse accumulator operate normally when the cpu is in wait mode.  if tswai is set, timer and pulse accumulator clock generation ceases and the tim module enters a power-conservation state when the cpu is in wait mode. in this condition, timer and pulse accumulator registers are not accessible. setting tswai does not affect the state of the timer enable bit, ten, or the pulse accumulator enable bit, paen.
standard timer module interrupt sources advance information MC68HC812A4 ? rev. 5.0 motorola standard timer module 207 12.9.3 stop mode the stop instruction disables the timer for reduced power consumption. 12.10 interrupt sources 12.11 general-purpose i/o ports this section describes the general-purpose i/o ports. table 12-5. timer interrupt sources interrupt source flag local enable ccr mask vector address timer channel 0 c0f c0i i bit $ffee, $ffef timer channel 1 c1f c1i i bit $ffec, $ffed timer channel 2 c2f c2i i bit $ffea, $ffeb timer channel 3 c3f c3i i bit $ffe8, $ffe9 timer channel 4 c4f c4i i bit $ffe6, $ffe7 timer channel 5 c5f c5i i bit $ffe4, $ffe5 timer channel 6 c6f c6i i bit $ffe2, $ffe3 timer channel 7 c7f c7i i bit $ffe0, $ffe1 timer overflow tof toi i bit $ffde, $ffdf pulse accumulator overflow paovf paovi i bit $ffdc, $ffdd pulse accumulator input paif pai i bit $ffda, $ffdb
MC68HC812A4 ? rev. 5.0 advance information 208 standard timer module motorola standard timer module 12.11.1 timer port data register an i/o pin used by the timer defaults to general-purpose i/o unless an internal function which uses that pin is enabled. read: anytime write: anytime pt7 ? pt0 ? timer port data bits data written to portt is buffered and drives the pins only when they are configured as general-purpose outputs. reading an input (data direction bit = 0) reads the pin state; reading an output (data direction bit = 1) reads the latch. writing to a pin configured as a timer output does not change the pin state. note: due to input synchronizer circuitry, the minimum pulse width for a pulse accumulator input or an input capture input should always be greater than the width of two module clocks. address: $00ae bit 7654321bit 0 read: pt7 pt6 pt5 pt4 pt3 pt2 pt1 pt0 write: reset: unaffected by reset timer function: ic/oc7 ic/oc6 ic/oc5 ic4oc4 ic/oc3 ic/oc2 ic/oc1 ic/oc0 pa function: pai figure 12-25. timer port data register (portt) table 12-6. timport i/o function in out data direction register output compare action reading at data bus reading at pin 00pin pin 0 1 pin output compare action 1 1 port data register output compare action 1 0 port data register port data register
standard timer module general-purpose i/o ports advance information MC68HC812A4 ? rev. 5.0 motorola standard timer module 209 12.11.2 timer port data direction register read: anytime write: anytime bits 7 ? 0 ? timport data direction bits these bits control the port logic of portt. reset clears the timer port data direction register, configuring all timer port pins as inputs. 1 = corresponding pin configured as output 0 = corresponding pin configured as input the timer forces the i/o state to be an output for each timer port pin associated with an enabled output compare. in these cases, the data direction bits do not change but have no effect on the direction of these pins. the ddrt reverts to controlling the i/o direction of a pin when the associated timer output compare is disabled. input captures do not override the ddrt settings. note: by setting the iosx bit input capture configuration no matter what the state of the data direction register is, the timer forces output compare pins to be outputs and input capture pins to be inputs. address: $00af bit 7654321bit 0 read: bit 7654321bit 0 write: reset:00000000 figure 12-26. timer port data direction register (ddrt)
MC68HC812A4 ? rev. 5.0 advance information 210 standard timer module motorola standard timer module 12.12 using the output compare function to generate a square wave this timer exercise is intended to utilize the output compare function to generate a square wave of predetermined duty cycle and frequency. square wave frequency 1000 hz, duty cycle 50% the program generates a square wave, 50 percent duty cycle, on output compare 2 (oc2). the signal will be measured by the m68hc11 on the udlp1 board. it assumes a 8.0 mhz operating frequency for the e clock. the control registers are initialized to disable interrupts, configure for proper pin control action and also the tc2h register for desired compare value. the appropiate count must be calculated to achieve the desired frequency and duty cycle. for example: for a 50 percent duty, 1 khz signal each period must consist of 2048 counts or 1024 counts high and 1024 counts low. in essence a $0400 is added to generate a frequency of 1 khz. 12.12.1 sample calculation to obtain period counts the sample calculation to obtain period counts is:  for 1000 hz frequency: ? e-clock = 8 mhz ? ic/oc resolution factor = 1/(e-clock/prescaler) ? if the prescaler = 4, then output compare resolution is 0.5 s  for a 1 khz, 50 percent duty cycle: ? 1/f = t = 1/1000 = 1 ms ? f for output compare = prescaler/e clock = 2 mhz figure 12-27. example waveform 0.5 ms number of clocks = f * d 1 ms therefore, # clocks = (2 mhz) * (0.5 ms) = 1024 = $0400
standard timer module using the output compare function to generate a square wave advance information MC68HC812A4 ? rev. 5.0 motorola standard timer module 211 12.12.2 equipment for this exercise, use the m68hc812a4evb emulation board. 12.12.3 code listing note: a comment line is delimited by a semicolon. if there is no code before comment, a semicolon ( ;) must be placed in the first column to avoid assembly errors. ---------------------------------------------------------------------- ; main program ; ---------------------------------------------------------------------- org $7000 ; 16k on-board ram, user code data area, ; ; start main program at $7000 main: bsr timerinit ; subroutine used to initialize the timer: ; ; output compare channel, no interrupts bsr sqwave ; subroutine to generate square wave done: bra done ; branch to itself, convinient for breakpoint ;* ----------------------------------------------------------------- ;* subroutine timerinit: initialize timer for output compare on oc2 ;* ----------------------------------------------------------------- timerinit: clr tmsk1 ; disable all interrupts movb #$02,tmsk2 ; disable overflow interrupt, disable pull-up ; ; resistor function with normal drive capability ;; and free running counter, prescaler = sys clock/4. movb #$10,tctl2 ; initialize oc2 to toggle on successful compare. movb #$04,tios ; select channel 2 to act as output compare. movw #$0400,tc2h ; load tc2 reg with initial compare value. movb #$80,tscr ; enable timer, timer runs during wait state, and ; ; while in background mode, also clear flags ; ; normally. rts ; return from subroutine
MC68HC812A4 ? rev. 5.0 advance information 212 standard timer module motorola standard timer module ;* ------------------------------ ;* subroutine: sqwave ;* ------------------------------ sqwave: ;* ------- clearflg: ;* ------- ;* to clear the c2f flag: 1) read tflg1 when ;* c2f is set and then 2) write a logic "one" to c2f. ldaa tflg1 ; to clear oc2 flag, first it must be read, oraa #$04 ; then a "1" must be written to it staa tflg1 wtflg: brclr tflg1,#$04,wtflg ; wait (polling) for c2f flag ldd tc2h ; loads value of compare from tc2 reg. addd #$0400 ; add hex value of 500us high time std tc2h ; set-up next transition time in 500 us bra clearflg ; continuously add 500 us, branch to clearflag rts ; return from subroutine end ; end of program
advance information MC68HC812A4 ? rev. 5.0 motorola multiple serial interface (msi) 213 advance information ? MC68HC812A4 section 13. multiple serial interface (msi) 13.1 contents 13.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .213 13.3 sci features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .214 13.4 spi features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .215 13.5 msi block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .215 13.6 msi register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .216 13.7 general-purpose i/o ports . . . . . . . . . . . . . . . . . . . . . . . . . . .218 13.7.1 port s data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . .219 13.7.2 port s data direction register . . . . . . . . . . . . . . . . . . . . . .220 13.7.3 port s pullup and reduced drive control . . . . . . . . . . . . .221 13.7.4 port s wired-or mode control . . . . . . . . . . . . . . . . . . . . .222 13.2 introduction the multiple serial interface (msi) module consists of three independent serial i/o interfaces:  two serial communication interfaces, sci0 and sci1  one serial peripheral interface, spi0 note: port s shares its pins with the multiple serial interface (msi). see 13.7 general-purpose i/o ports .
MC68HC812A4 ? rev. 5.0 advance information 214 multiple serial interface (msi) motorola multiple serial interface (msi) 13.3 sci features serial comunication interface (sci) features include:  full-duplex operation  standard mark/space non-return-to-zero (nrz) format  13-bit baud rate selection  programmable 8-bit or 9-bit data format  separately enabled transmitter and receiver  separate receiver and transmitter interrupt requests  two receiver wakeup methods: ? idle line wakeup ? address mark wakeup  five flags with interrupt-generation capability: ? transmitter empty ? transmission complete ? receiver full ? receiver overrun ? idle receiver input  receiver noise error detection  receiver framing error detection  receiver parity error detection for additional information, refer to section 14. serial communications interface module (sci) .
multiple serial interface (msi) spi features advance information MC68HC812A4 ? rev. 5.0 motorola multiple serial interface (msi) 215 13.4 spi features serial preipheral interface (spi) fetures include:  full-duplex operation  master mode and slave mode  programmable slave-select output option  programmable bidirectional data pin option  interrupt-driven operation with two flags: ? transmission complete ? mode fault  read data buffer  serial clock with programmable polarity and phase  reduced drive control for lower power consumption  programmable open-drain output option for additional information, refer to section 15. serial peripheral interface (spi) 13.5 msi block diagram figure 13-1. multiple serial interface block diagram sci0 sci1 spi0 ddrs/ioctlr port s i/o drivers msi ps0 ps1 ps2 ps3 ps4 ps5 ps6 ps7 rxd0 txd0 rxd1 txd1 miso/siso mosi/momi sck cs /ss
MC68HC812A4 ? rev. 5.0 advance information 216 multiple serial interface (msi) motorola multiple serial interface (msi) 13.6 msi register map addr.register name bit 7654321bit 0 $00c0 sci 0 baud rate register high (sc0bdh) see page 249. read: btst bspl brld sbr12 sbr11 sbr10 sbr9 sbr8 write: reset:00000000 $00c1 sci 0 baud rate register low (sc0bdl) see page 249. read: sbr7 sbr6 sbr5 sbr4 sbr3 sbr2 sbr1 sbr0 write: reset:00000100 $00c2 sci 0 control register 1 (sc0cr1) see page 250. read: loops woms rsrc m wake ilt pe pt write: reset:00000000 $00c3 sci 0 control register 2 (sc0cr2) see page 252. read: tie tcie rie ilie te re rwu sbk write: reset:00000000 $00c4 sci 0 status register 1 (sc0sr1) see page 254. read: tdre tc rdrf idle or nf fe pf write: reset:11000000 $00c5 sci 0 status register 2 (sc0sr2) see page 256. read: 0000000raf write: reset:00000000 $00c6 sci 0 data register high (sc0drh) see page 257. read: r8 t8 000000 write: reset: unaffected by reset $00c7 sci 0 data register low (sc0drl) see page 257. read: r7 r6 r5 r4 r3 r2 r1 r0 write: t7 t6 t5 t4 t3 t2 t1 t0 reset: unaffected by reset = unimplemented figure 13-2. msi register map (sheet 1 of 3)
multiple serial interface (msi) msi register map advance information MC68HC812A4 ? rev. 5.0 motorola multiple serial interface (msi) 217 $00c8 sci 1 baud rate register high (sc1bdh) see page 249. read: btst bspl brld sbr12 sbr11 sbr10 sbr9 sbr8 write: reset:00000000 $00c9 sci 1 baud rate register low (sc1bdl) see page 249. read: sbr7 sbr6 sbr5 sbr4 sbr3 sbr2 sbr1 sbr0 write: reset:00000100 $00ca sci 1 control register 1 (sc1cr1) see page 250. read: loops woms rsrc m wake ilt pe pt write: reset:00000000 $00cb sci 1 control register 2 (sc1cr2) see page 252. read: tie tcie rie ilie te re rwu sbk write: reset:00000000 $00cc sci 1 status register 1 (sc1sr1) see page 254. read: tdre tc rdrf idle or nf fe pf write: reset:11000000 $00cd sci 1 status register 2 (sc1sr2) see page 256. read: 0000000raf write: reset:00000000 $00ce sci 1 data register high (sc1drh) see page 257. read: r8 t8 000000 write: reset: unaffected by reset $00cf sci 1 data register low (sc1drl) see page 257. read: r7 r6 r5 r4 r3 r2 r1 r0 write: t7 t6 t5 t4 t3 t2 t1 t0 reset: unaffected by reset $00d0 spi 0 control register 1 (sp0cr1) see page 273. read: spie spe swom mstr cpol cpha ssoe lsbf write: reset:00000000 addr.register name bit 7654321bit 0 = unimplemented figure 13-2. msi register map (sheet 2 of 3)
MC68HC812A4 ? rev. 5.0 advance information 218 multiple serial interface (msi) motorola multiple serial interface (msi) full register descriptions can be found in section 14. serial communications interface module (sci) and section 15. serial peripheral interface (spi) . 13.7 general-purpose i/o ports port s shares its pins with the multiple serial interface (msi). in all modes, port s pins ps7 ? ps0 are available for either general-purpose i/o or for sci and spi functions. $00d1 spi 0 control register 2 (sp0cr2) see page 275. read: 0000 pups rds 0 spc0 write: reset:00001000 $00d2 spi 0 baud rate register (sp0br) see page 276. read: 00000 spr2 spr1 spr0 write: reset:00000000 $00d3 spi 0 status register (sp0sr) see page 277. read: spif wcol 0 modf 0 0 0 0 write: reset:00000000 $00d5 spi 0 data register (sp0dr) see page 278. read: bit 76543210 write: reset: unaffected by reset $00d6 port s data register (ports) see page 219. read: ps7 ps6 ps5 ps4 ps3 ps2 ps1 ps0 write: reset: unaffected by reset $00d7 port s data direction register (ddrs) see page 220. read: ddrs7 ddrs6 ddrs5 ddrs4 ddrs3 ddrs2 ddrs1 ddrs0 write: reset:00000000 addr.register name bit 7654321bit 0 = unimplemented figure 13-2. msi register map (sheet 3 of 3)
multiple serial interface (msi) general-purpose i/o ports advance information MC68HC812A4 ? rev. 5.0 motorola multiple serial interface (msi) 219 13.7.1 port s data register read: anytime write: anytime ps7 ? ps4 ? port s data bits 7 ? 4 port s shares ps7 ? ps4 with spi0. ss is the spi0 slave-select terminal. sck is the spi0 serial clock terminal. mosi is the spi0 master out, slave in terminal. miso is the spi0 master in, slave out terminal. ps3 ? ps0 ? port s data bits 3 ? 0 port s shares ps3 ? 0 with sci1 and sci0. txd1 is the sci1 transmit terminal. rxd1 is the sci1 receive terminal. txd0 is the sci0 transmit terminal. rxd0 is the sci0 receive terminal. note: reading a port s bit when its data direction bit is clear returns the level of the voltage on the pin. reading a port s bit when its data direction bit is set returns the level of the voltage of the pin driver input. a write to a port s bit is stored in an internal latch. the latch drives the pin only when the corresponding data direction bit is set. writes do not change the pin state when the pin is configured for sci output. address: $00d6 bit 7654321bit 0 read: ps7 ps6 ps5 ps4 ps3 ps2 ps1 ps0 write: reset: unaffected by reset pin function: ss sck mosi miso txd1 rxd1 txd0 rxd0 figure 13-3. port s data register (ports)
MC68HC812A4 ? rev. 5.0 advance information 220 multiple serial interface (msi) motorola multiple serial interface (msi) 13.7.2 port s data direction register read: anytime write: anytime ddrs7 ? ddrs0 ? port s data direction bits these bits control the data direction of each port s pin. setting a ddrs bit makes the pin an output; clearing a ddrs bit makes the pin an input. reset clears the port s data direction register, configuring all port s pins as inputs. 1 = corresponding port s pin configured as output 0 = corresponding port s pin configured as input note: when the loops bit is clear, the rx pins of sci0 and sci1 are inputs and the tx pins are outputs regardless of their ddrs bits. when the spi is enabled, an spi input pin is an input regardless of its ddrs bit. when the spi is enabled, an spi output is an output only if its ddrs bit is set. when the ddrs bit of an spi output is clear, the pin is available for general-purpose i/o. address: $00d7 bit 7654321bit 0 read: ddrs7 ddrs6 ddrs5 ddrs4 ddrs3 ddrs2 ddrs1 ddrs0 write: reset:00000000 figure 13-4. port s data direction register (ddrs)
multiple serial interface (msi) general-purpose i/o ports advance information MC68HC812A4 ? rev. 5.0 motorola multiple serial interface (msi) 221 13.7.3 port s pullup and reduced drive control read: anytime write: anytime pups ? pullup port s enable bit setting pups enables internal pullup devices on all port s input pins. if a pin is programmed as output, the pullup device becomes inactive. 1 = pullups enabled 0 = pullups disabled rds ? reduced drive port s bit setting rds lowers the drive capability of all port s output pins for lower power consumption and less noise. 1 = reduced drive 0 = full drive spc0 ? see section 14. serial communications interface module (sci) . address: $00d1 bit 7654321bit 0 read: 0 0 0 0 pups rds 0 spc0 write: reset:00001000 = unimplemented figure 13-5. spi control register 2 (sp0cr2) table 13-1. port s pullup and reduced drive enable register pullups reduced drive control bit pins affected reset state control bit pins affected reset state spi control register 2 (sp0cr2) pups ps7 ? ps0 enabled rds ps7 ? ps0 disabled
MC68HC812A4 ? rev. 5.0 advance information 222 multiple serial interface (msi) motorola multiple serial interface (msi) 13.7.4 port s wired-or mode control table 13-2. port s wired-or mode enable register control bit pins affected reset state spi control register 1 (sp0cr1) swom ps7 ? ps4 disabled sci0 control register 1 (sc0cr1) woms ps3, ps2 disabled sci1 control register 1 (sc1cr1) woms ps1, ps0 disabled
advance information MC68HC812A4 ? rev. 5.0 motorola serial communications interface module (sci) 223 advance information ? MC68HC812A4 section 14. serial communications interface module (sci) 14.1 contents 14.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .224 14.3 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .224 14.4 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .226 14.5 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .227 14.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .229 14.6.1 data format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .229 14.6.2 baud rate generation . . . . . . . . . . . . . . . . . . . . . . . . . . . .230 14.6.3 transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .232 14.6.3.1 character length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .233 14.6.3.2 character transmission . . . . . . . . . . . . . . . . . . . . . . . . .233 14.6.3.3 break characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .234 14.6.3.4 idle characters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .235 14.6.4 receiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .236 14.6.4.1 character length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .237 14.6.4.2 character reception . . . . . . . . . . . . . . . . . . . . . . . . . . .237 14.6.4.3 data sampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .237 14.6.4.4 framing errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .243 14.6.4.5 baud rate tolerance . . . . . . . . . . . . . . . . . . . . . . . . . . .243 14.6.4.6 receiver wakeup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .245 14.6.5 single-wire operation . . . . . . . . . . . . . . . . . . . . . . . . . . . .247 14.6.6 loop operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .248 14.7 register descriptions and reset initialization . . . . . . . . . . . . 248 14.7.1 sci baud rate registers . . . . . . . . . . . . . . . . . . . . . . . . . .249 14.7.2 sci control register 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . .250 14.7.3 sci control register 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . .252 14.7.4 sci status register 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . .254 14.7.5 sci status register 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . .256 14.7.6 sci data registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .257
MC68HC812A4 ? rev. 5.0 advance information 224 serial communications interface module (sci) motorola serial communications interface module (sci) 14.8 external pin descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . .258 14.8.1 txd pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 14.8.2 rxd pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 14.9 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .259 14.10 low-power options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .259 14.10.1 run mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .259 14.10.2 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .259 14.10.3 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .259 14.11 interrupt sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .260 14.12 general-purpose i/o ports . . . . . . . . . . . . . . . . . . . . . . . . . . .260 14.13 serial character transmission using the sci . . . . . . . . . . . .260 14.13.1 equipment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .260 14.13.2 code listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .261 14.2 introduction the serial communications interface (sci) allows asynchronous serial communications with peripheral devices and other mcus. 14.3 features features of the sci include:  full-duplex operation  standard mark/space non-return-to-zero (nrz) format  13-bit baud rate selection  programmable 8-bit or 9-bit data format  separately enabled transmitter and receiver  separate receiver and transmitter interrupt requests  two receiver wakeup methods: ? idle line wakeup ? address mark wakeup
serial communications interface module (sci) features advance information MC68HC812A4 ? rev. 5.0 motorola serial communications interface module (sci) 225  five flags with interrupt-generation capability: ? transmitter empty ? transmission complete ? receiver full ? receiver overrun ? idle receiver input  receiver noise error detection  receiver framing error detection  receiver parity error detection
MC68HC812A4 ? rev. 5.0 advance information 226 serial communications interface module (sci) motorola serial communications interface module (sci) 14.4 block diagram figure 14-1. sci block diagram sci data receive shift register sci data register transmit shift register register baud rate generator sbr[12:0] rxd module transmit control 16 receive and wakeup data format control control t8 pf fe nf rdrf idle tie or tcie tdre tc r8 raf loops rwu re pe ilt pt wake m clock sci ilie rie sci sci sci interrupt interrupt interrupt interrupt rsrc sbk loops te rsrc request request request request woms port s data direction register port s data reister 3 210 pin control logic txd1 rxd1 txd0 rxd0 txd rxd to sci1 txd from sci1
serial communications interface module (sci) register map advance information MC68HC812A4 ? rev. 5.0 motorola serial communications interface module (sci) 227 14.5 register map note: the register block can be mapped to any 2-kbyte boundary within the standard 64-kbyte address space. the register block occupies the first 512 bytes of the 2-kbyte block. this register map shows default addressing after reset. addr.register name bit 7654321bit 0 $00c0 sci 0 baud rate register high (sc0bdh) see page 249. read: btst bspl brld sbr12 sbr11 sbr10 sbr9 sbr8 write: reset:00000000 $00c1 sci 0 baud rate register low (sc0bdl) see page 249. read: sbr7 sbr6 sbr5 sbr4 sbr3 sbr2 sbr1 sbr0 write: reset:00000100 $00c2 sci 0 control register 1 (sc0cr1) see page 250. read: loops woms rsrc m wake ilt pe pt write: reset:00000000 $00c3 sci 0 control register 2 (sc0cr2) see page 252. read: tie tcie rie ilie te re rwu sbk write: reset:00000000 $00c4 sci 0 status register 1 (sc0sr1) see page 254. read: tdre tc rdrf idle or nf fe pf write: reset:11000000 $00c5 sci 0 status register 2 (sc0sr2) see page 256. read: 0000000raf write: reset:00000000 $00c6 sci 0 data register high (sc0drh) see page 257. read: r8 t8 000000 write: reset: unaffected by reset = unimplemented figure 14-2. sci register map (sheet 1 of 2)
MC68HC812A4 ? rev. 5.0 advance information 228 serial communications interface module (sci) motorola serial communications interface module (sci) $00c7 sci 0 data register low (sc0drl) see page 257. read: r7 r6 r5 r4 r3 r2 r1 r0 write: t7 t6 t5 t4 t3 t2 t1 t0 reset: unaffected by reset $00c8 sci 1 baud rate register high (sc1bdh) see page 249. read: btst bspl brld sbr12 sbr11 sbr10 sbr9 sbr8 write: reset:00000000 $00c9 sci 1 baud rate register low (sc1bdl) see page 249. read: sbr7 sbr6 sbr5 sbr4 sbr3 sbr2 sbr1 sbr0 write: reset:00000100 $00ca sci 1 control register 1 (sc1cr1) see page 250. read: loops woms rsrc m wake ilt pe pt write: reset:00000000 $00cb sci 1 control register 2 (sc1cr2) see page 252. read: tie tcie rie ilie te re rwu sbk write: reset:00000000 $00cc sci 1 status register 1 (sc1sr1) see page 254. read: tdre tc rdrf idle or nf fe pf write: reset:11000000 $00cd sci 1 status register 2 (sc1sr2) see page 256. read: 0000000raf write: reset:00000000 $00ce sci 1 data register high (sc1drh) see page 257. read: r8 t8 000000 write: reset: unaffected by reset $00cf sci 1 data register low (sc1drl) see page 257. read: r7 r6 r5 r4 r3 r2 r1 r0 write: t7 t6 t5 t4 t3 t2 t1 t0 reset: unaffected by reset addr.register name bit 7654321bit 0 = unimplemented figure 14-2. sci register map (sheet 2 of 2)
serial communications interface module (sci) functional description advance information MC68HC812A4 ? rev. 5.0 motorola serial communications interface module (sci) 229 14.6 functional description the sci allows full-duplex, asynchronous, nrz serial communication between the mcu and remote devices, including other mcus. the sci transmitter and receiver operate independently, although they use the same baud rate generator. the cpu monitors the status of the sci, writes the data to be transmitted, and processes received data. 14.6.1 data format the sci uses the standard nrz mark/space data format illustrated in figure 14-3 . figure 14-3. sci data formats each data character is contained in a frame that includes a start bit, eight or nine data bits, and a stop bit. clearing the m bit in sci control register 1 configures the sci for 8-bit data characters. a frame with eight data bits has a total of 10 bits. setting the m bit configures the sci for 9-bit data characters. a frame with nine data bits has a total of 11 bits. table 14-1. example 8-bit data formats start bit data bits address bit parity bit stop bit 18001 170 2 17011 17 1 (1) 1. the address bit identifies the frame as an address character. see 14.6.4.6 receiver wakeup . 1 bit 5 start bit bit 0 bit 1 next stop bit start bit 9-bit data format bit 2 bit 3 bit 4 bit 6 bit 7 parity or data bit parity or data bit bit m in sccr1 set 8-bit data format bit m in sccr1 clear bit 5 bit 0 bit 1 bit 2 bit 3 bit 4 bit 6 bit 7 bit 8 stop bit next start bit start bit
MC68HC812A4 ? rev. 5.0 advance information 230 serial communications interface module (sci) motorola serial communications interface module (sci) setting the m bit configures the sci for 9-bit data characters. the ninth data bit is the t8 bit in sci data register high (scdrh). it remains unchanged after transmission and can be used repeatedly without rewriting it. a frame with nine data bits has a total of 11 bits. 14.6.2 baud rate generation a 13-bit modulus counter in the baud rate generator derives the baud rate for both the receiver and the transmitter. the value from 0 to 8191 written to the sbr12 ? sbr0 bits determines the module clock divisor. the sbr bits are in the sci baud rate registers (scbdh and scbdl). the baud rate clock is synchronized with the bus clock and drives the receiver. the baud rate clock divided by 16 drives the transmitter. the receiver has an acquisition rate of 16 samples per bit time. baud rate generation is subject to two sources of error:  integer division of the module clock may not give the exact target frequency.  synchonization with the bus clock can cause phase shift. table 14-3 lists some examples of achieving target baud rates with a module clock frequency of 10.2 mhz. table 14-2. example 9-bit data formats start bit data bits address bit parity bit stop bit 19001 180 2 18011 18 1 (1) 1. the address bit identifies the frame as an address character. see 14.6.4.6 receiver wakeup . 1
serial communications interface module (sci) functional description advance information MC68HC812A4 ? rev. 5.0 motorola serial communications interface module (sci) 231 table 14-3. baud rates (module clock = 10.2 mhz) baud rate divisor (1) 1. the baud rate divisor is the value written to the sbr12 ? sbr0 bits. receiver clock rate (hz) (2) 2. the receiver clock frequency is the mclk frequency divided by the baud rate divisor. transmitter clock rate (hz) (3) 3. the transmitter clock frequency is the receiver clock frequency divided by 16. target baud rate error (%) 17 600,000.0 37,500.0 38,400 2.3 33 309,090.9 19,318.2 19,200 0.62 66 154,545.5 9659.1 9600 0.62 133 76,691.7 4793.2 4800 0.14 266 38,345.9 2396.6 2400 0.14 531 19,209.0 1200.6 1200 0.11 1062 9604.5 600.3 600 0.05 2125 4800.0 300.0 300 0.00 4250 2400.0 150.0 150 0.00 5795 1760.1 110.0 110 0.00
MC68HC812A4 ? rev. 5.0 advance information 232 serial communications interface module (sci) motorola serial communications interface module (sci) 14.6.3 transmitter a block diagram of the sci transmitter is shown in figure 14-4 . figure 14-4. sci transmitter block diagram pe pt h876543210l 11-bit transmit shift register stop start t8 tdre tie tcie sbk tc parity generation msb sci data registers load from scidr shift enable preamble (all 1s) break (all 0s) transmitter control m internal bus sbr12 ? sbr0 baud divider 16 txd sci interrupt request sci interrupt request module loop loops rsrc clock te to control receiver
serial communications interface module (sci) functional description advance information MC68HC812A4 ? rev. 5.0 motorola serial communications interface module (sci) 233 14.6.3.1 character length the sci transmitter can accommodate either 8-bit or 9-bit data characters. the state of the m bit in sci control register 1 (sccr1) determines the length of data characters. when transmitting 9-bit data, bit t8 in sci data register high (scdrh) is the ninth bit (bit 8). 14.6.3.2 character transmission during an sci transmission, the transmit shift register shifts a frame out to the txd pin. the sci data registers (scdrh and scdrl) are the write-only buffers between the internal data bus and the transmit shift register. to initiate an sci transmission: 1. enable the transmitter by writing a logic 1 to the transmitter enable bit, te, in sci control register 2 (sccr2). 2. clear the transmit data register empty flag, tdre, by first reading sci status register 1 (scsr1) and then writing to sci data register low (scdrl). in 9-data-bit format, write the ninth bit to the t8 bit in sci data register high (scdrh). 3. repeat step 2 for each subsequent transmission. writing the te bit from 0 to 1 automatically loads the transmit shift register with a preamble of 10 logic 1s (if m = 0) or 11 logic 1s (if m = 1). after the preamble shifts out, control logic transfers the data from the sci data register into the transmit shift register. a logic 0 start bit automatically goes into the least significant bit position of the transmit shift register. a logic 1 stop bit goes into the most significant bit position. hardware supports odd or even parity. when parity is enabled, the most significant bit (msb) of the data character is the parity bit. the transmit data register empty flag, tdre, in sci status register 1 (scsr1) becomes set when the sci data register transfers a byte to the transmit shift register. the tdre flag indicates that the sci data register can accept new data from the internal data bus. if the transmit interrupt enable bit, tie, in sci control register 2 (sccr2) is also set, the tdre flag generates an sci interrupt request.
MC68HC812A4 ? rev. 5.0 advance information 234 serial communications interface module (sci) motorola serial communications interface module (sci) when the transmit shift register is not transmitting a frame, the txd pin goes to the idle condition, logic 1. if at any time software clears the te bit in sci control register 2 (sccr2), the transmitter and receiver relinquish control of the port i/o pins. if software clears te while a transmission is in progress (tc = 0), the frame in the transmit shift register continues to shift out. then the txd pin reverts to being a general-purpose i/o pin even if there is data pending in the sci data register. to avoid accidentally cutting off the last frame in a message, always wait for tdre to go high after the last frame before clearing te. to separate messages with preambles with minimum idle line time, use this sequence between messages: 1. write the last byte of the first message to scdrh/l. 2. wait for the tdre flag to go high, indicating the transfer of the last frame to the transmit shift register. 3. queue a preamble by clearing and then setting the te bit. 4. write the first byte of the second message to scdrh/l. when the sci relinquishes the txd pin, the ports and ddrs registers control the txd pin. to force txd high when turning off the transmitter, set bit 1 of the port s register (ports) and bit 1 of the port s data direction register (ddrs). the txd pin goes high as soon as the sci relinquishes it. 14.6.3.3 break characters writing a logic 1 to the send break bit, sbk, in sci control register 2 (sccr2) loads the transmit shift register with a break character. a break character contains all logic 0s and has no start, stop, or parity bit. break character length depends on the m bit in sci control register 1 (sccr1). as long as sbk is at logic 1, transmitter logic continuously loads break characters into the transmit shift register. after software clears the sbk bit, the shift register finishes transmitting the last break character and then transmits at least one logic 1. the automatic logic 1 at the end of a
serial communications interface module (sci) functional description advance information MC68HC812A4 ? rev. 5.0 motorola serial communications interface module (sci) 235 break character guarantees the recognition of the start bit of the next frame. the sci recognizes a break character when a start bit is followed by eight or nine logic 0 data bits and a logic 0 where the stop bit should be. receiving a break character has these effects on sci registers:  sets the framing error flag, fe  sets the receive data register full flag, rdrf  clears the sci data registers, scdrh/l  may set the overrun flag, or, noise flag, nf, parity error flag, pe, or the receiver active flag, raf (see 14.7.4 sci status register 1 ) 14.6.3.4 idle characters an idle character contains all logic 1s and has no start, stop, or parity bit. idle character length depends on the m bit in sci control register 1 (sccr1). the preamble is a synchronizing idle character that begins the first transmission initiated after writing the te bit from 0 to 1. if the te bit is cleared during a transmission, the txd pin becomes idle after completion of the transmission in progress. clearing and then setting the te bit during a transmission queues an idle character to be sent after the frame currently being transmitted. note: when queueing an idle character, return the te bit to logic 1 before the stop bit of the current frame shifts out to the txd pin. setting te after the stop bit appears on txd causes data previously written to the sci data register to be lost. toggle the te bit for a queued idle character when the tdre flag becomes set and immediately before writing the next byte to the sci data register.
MC68HC812A4 ? rev. 5.0 advance information 236 serial communications interface module (sci) motorola serial communications interface module (sci) 14.6.4 receiver a block diagram of the sci receiver is shown in figure 14-5 . figure 14-5. sci receiver block diagram all 1s m wake ilt pe pt re h876543210l 11-bit receive shift register stop start data wakeup parity checking msb sci data register r8 rie ilie rwu rdrf or nf fe pe internal bus rxd module sci interrupt request sci interrupt request sbr12 ? sbr0 baud divider loop loops rsrc from txd pin or transmitter clock idle raf recovery control logic
serial communications interface module (sci) functional description advance information MC68HC812A4 ? rev. 5.0 motorola serial communications interface module (sci) 237 14.6.4.1 character length the sci receiver can accommodate either 8-bit or 9-bit data characters. the state of the m bit in sci control register 1 (sccr1) determines the length of data characters. when receiving 9-bit data, bit r8 in sci data register high (scdrh) is the ninth bit (bit 8). 14.6.4.2 character reception during an sci reception, the receive shift register shifts a frame in from the rxd pin. the sci data register is the read-only buffer between the internal data bus and the receive shift register. after a complete frame shifts into the receive shift register, the data portion of the frame transfers to the sci data register. the receive data register full flag, rdrf, in sci status register 1 (scsr1) becomes set, indicating that the received byte can be read. if the receive interrupt enable bit, rie, in sci control register 2 (sccr2) is also set, the rdrf flag generates an interrupt request. 14.6.4.3 data sampling the receiver samples the rxd pin at the rt clock rate. the rt clock is an internal signal with a frequency 16 times the baud rate. to adjust for baud rate mismatch, the rt clock (see figure 14-6 ) is resynchronized:  after every start bit  after the receiver detects a data bit change from logic 1 to logic 0 (after the majority of data bit samples at rt8, rt9, and rt10 returns a valid logic 1 and the majority of the next rt8, rt9, and rt10 samples returns a valid logic 0) to locate the start bit, data recovery logic does an asynchronous search for a logic 0 preceded by three logic 1s. when the falling edge of a possible start bit occurs, the rt clock begins to count to 16.
MC68HC812A4 ? rev. 5.0 advance information 238 serial communications interface module (sci) motorola serial communications interface module (sci) figure 14-6. receiver data sampling to verify the start bit and to detect noise, data recovery logic takes samples at rt3, rt5, and rt7. table 14-4 summarizes the results of the start bit verification samples. if start bit verification is not successful, the rt clock is reset and a new search for a start bit begins. reset rt clock rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt5 rt8 rt7 rt6 rt11 rt10 rt9 rt15 rt14 rt13 rt12 rt16 rt1 rt2 rt3 rt4 samples rt clock rt clock count start bit rxd start bit qualification start bit data sampling 11 1 1 1 1 110000 0 00 lsb verification table 14-4. start bit verification rt3, rt5, and rt7 samples start bit verification noise flag 000 yes 0 001 yes 1 010 yes 1 011 no 0 100 yes 1 101 no 0 110 no 0 111 no 0
serial communications interface module (sci) functional description advance information MC68HC812A4 ? rev. 5.0 motorola serial communications interface module (sci) 239 to determine the value of a data bit and to detect noise, recovery logic takes samples at rt8, rt9, and rt10. table 14-5 summarizes the results of the data bit samples. note: the rt8, rt9, and rt10 samples do not affect start bit verification. if any or all of the rt8, rt9, and rt10 start bit samples are logic 1s following a successful start bit verification, the noise flag (nf) is set and the receiver assumes that the bit is a start bit (logic 0). to verify a stop bit and to detect noise, recovery logic takes samples at rt8, rt9, and rt10. table 14-6 summarizes the results of the stop bit samples. table 14-5. data bit recovery rt8, rt9, and rt10 samples data bit determination noise flag 000 0 0 001 0 1 010 0 1 011 1 1 100 0 1 101 1 1 110 1 1 111 1 0 table 14-6. stop bit recovery rt8, rt9, and rt10 samples framing error flag noise flag 000 1 0 001 1 1 010 1 1 011 0 1 100 1 1 101 0 1 110 0 1 111 0 0
MC68HC812A4 ? rev. 5.0 advance information 240 serial communications interface module (sci) motorola serial communications interface module (sci) in figure 14-7 the verification samples rt3 and rt5 determine that the first low detected was noise and not the beginning of a start bit. the rt clock is reset and the start bit search begins again. the noise flag is not set because the noise occurred before the start bit was found. in figure 14-8 noise is perceived as the beginning of a start bit although the verification sample at rt3 is high. the rt3 sample sets the noise flag. although the perceived bit time is misaligned, the data samples rt8, rt9, and rt10 are within the bit time and data recovery is successful. figure 14-7. start bit search example 1 figure 14-8. start bit search example 2 reset rt clock rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt5 rt1 rt1 rt2 rt3 rt4 rt7 rt6 rt5 rt10 rt9 rt8 rt14 rt13 rt12 rt11 rt15 rt16 rt1 rt2 rt3 samples rt clock rt clock count start bit rxd 11 0 1 111000 00 lsb 0 0 reset rt clock rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt5 rt6 rt7 rt8 rt11 rt10 rt9 rt14 rt13 rt12 rt2 rt1 rt16 rt15 rt3 rt4 rt5 rt6 rt7 samples rt clock rt clock count actual start bit rxd 11 1 1 11000 0 lsb 0 0 perceived start bit
serial communications interface module (sci) functional description advance information MC68HC812A4 ? rev. 5.0 motorola serial communications interface module (sci) 241 in figure 14-9 a large burst of noise is perceived as the beginning of a start bit, although the test sample at rt5 is high. the rt5 sample sets the noise flag. although this is a worst-case misalignment of perceived bit time, the data samples rt8, rt9, and rt10 are within the bit time and data recovery is successful. figure 14-10 shows the effect of noise early in the start bit time. although this noise does not affect proper synchronization with the start bit time, it does set the noise flag. figure 14-9. start bit search example 3 figure 14-10. start bit search example 4 reset rt clock rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt5 rt6 rt7 rt8 rt9 rt10 rt13 rt12 rt11 rt16 rt15 rt14 rt4 rt3 rt2 rt1 rt5 rt6 rt7 rt8 rt9 samples rt clock rt clock count actual start bit rxd 10 1 11000 0 lsb 0 perceived start bit reset rt clock rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt7 rt6 rt5 rt10 rt9 rt8 rt14 rt13 rt12 rt11 rt15 rt16 rt1 rt2 rt3 samples rt clock rt clock count perceived and actual start bit rxd 11 1 1100 1 lsb 1 1 1 1
MC68HC812A4 ? rev. 5.0 advance information 242 serial communications interface module (sci) motorola serial communications interface module (sci) figure 14-11 shows a burst of noise near the beginning of the start bit that resets the rt clock. the sample after the reset is low but is not preceded by three high samples that would qualify as a falling edge. depending on the timing of the start bit search and on the data, the frame may be missed entirely or it may set the framing error flag. in figure 14-12 a noise burst makes the majority of data samples rt8, rt9, and rt10 high. this sets the noise flag but does not reset the rt clock. in start bits only, the rt8, rt9, and rt10 data samples are ignored. figure 14-11. start bit search example 5 figure 14-12. start bit search example 6 reset rt clock rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt7 rt6 rt5 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 samples rt clock rt clock count start bit rxd 11 1 1101 0 lsb 1 1 1 1 1 00 0 00 0 0 0 no start bit found reset rt clock rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt7 rt6 rt5 rt10 rt9 rt8 rt14 rt13 rt12 rt11 rt15 rt16 rt1 rt2 rt3 samples rt clock rt clock count start bit rxd 11 1 1100 0 lsb 1 1 1 1 0 11 0
serial communications interface module (sci) functional description advance information MC68HC812A4 ? rev. 5.0 motorola serial communications interface module (sci) 243 14.6.4.4 framing errors if the data recovery logic does not detect a logic 1 where the stop bit should be in an incoming frame, it sets the framing error flag, fe, in sci status register 1 (scsr1). a break character also sets the fe flag because a break character has no stop bit. the fe flag is set at the same time that the rdrf flag is set. 14.6.4.5 baud rate tolerance a transmitting device may be operating at a baud rate below or above the receiver baud rate. accumulated bit time misalignment can cause one of the three stop bit data samples to fall outside the actual stop bit. then a noise error occurs. if more than one of the samples is outside the stop bit, a framing error occurs. in most applications, the baud rate tolerance is much more than the degree of misalignment that is likely to occur. as the receiver samples an incoming frame, it resynchronizes the rt clock on any valid falling edge within the frame. resynchronization within frames corrects misalignments between transmitter bit times and receiver bit times. slow data tolerance figure 14-13 shows how much a slow received frame can be misaligned without causing a noise error or a framing error. the slow stop bit begins at rt8 instead of rt1 but arrives in time for the stop bit data samples at rt8, rt9, and rt10. figure 14-13. slow data msb stop rt1 rt2 rt3 rt4 rt5 rt6 rt7 rt8 rt9 rt10 rt11 rt12 rt13 rt14 rt15 rt16 data samples receiver rt clock
MC68HC812A4 ? rev. 5.0 advance information 244 serial communications interface module (sci) motorola serial communications interface module (sci) for an 8-bit data character, data sampling of the stop bit takes the receiver 9 bit times 16 rt cycles + 10 rt cycles = 154 rt cycles. with the misaligned character shown in figure 14-13 , the receiver counts 154 rt cycles at the point when the count of the transmitting device is 9 bit times 16 rt cycles + 3 rt cycles = 147 rt cycles. the maximum percent difference between the receiver count and the transmitter count of a slow 8-bit data character with no errors is: for a 9-bit data character, data sampling of the stop bit takes the receiver 10 bit times 16 rt cycles + 10 rt cycles = 170 rt cycles. with the misaligned character shown in figure 14-13 , the receiver counts 170 rt cycles at the point when the count of the transmitting device is: 10 bit times 16 rt cycles + 3 rt cycles = 163 rt cycles. the maximum percent difference between the receiver count and the transmitter count of a slow 9-bit character with no errors is: fast data tolerance figure 14-14 shows how much a fast received frame can be misaligned without causing a noise error or a framing error. the fast stop bit ends at rt10 instead of rt16 but is still sampled at rt8, rt9, and rt10. figure 14-14. fast data 154 147 ? 154 ------------------------- - 100 4.54% = 170 163 ? 170 ------------------------- - 100 4.12% = idle or next frame stop rt1 rt2 rt3 rt4 rt5 rt6 rt7 rt8 rt9 rt10 rt11 rt12 rt13 rt14 rt15 rt16 data samples receiver rt clock
serial communications interface module (sci) functional description advance information MC68HC812A4 ? rev. 5.0 motorola serial communications interface module (sci) 245 for an 8-bit data character, data sampling of the stop bit takes the receiver 9 bit times 16 rt cycles + 10 rt cycles = 154 rt cycles. with the misaligned character shown in figure 14-14 , the receiver counts 154 rt cycles at the point when the count of the transmitting device is 10 bit times 16 rt cycles = 160 rt cycles. the maximum percent difference between the receiver count and the transmitter count of a fast 8-bit character with no errors is: for a 9-bit data character, data sampling of the stop bit takes the receiver 10 bit times 16 rt cycles + 10 rt cycles = 170 rt cycles. with the misaligned character shown in figure 14-14 , the receiver counts 170 rt cycles at the point when the count of the transmitting device is: 11 bit times 16 rt cycles = 176 rt cycles. the maximum percent difference between the receiver count and the transmitter count of a fast 9-bit character with no errors is: 14.6.4.6 receiver wakeup so that the sci can ignore transmissions intended only for other receivers in multiple-receiver systems, the receiver can be put into a standby state. setting the receiver wakeup bit, rwu, in sci control register 2 (sccr2) puts the receiver into a standby state during which receiver interrupts are disabled. the transmitting device can address messages to selected receivers by including addressing information in the initial frame or frames of each message. 154 160 ? 154 ------------------------- - 100 3.90% = 170 176 ? 170 ------------------------- - 100 3.53% =
MC68HC812A4 ? rev. 5.0 advance information 246 serial communications interface module (sci) motorola serial communications interface module (sci) the wake bit in sci control register 1 (sccr1) determines how the sci is brought out of the standby state to process an incoming message. the wake bit enables either idle line wakeup or address mark wakeup:  idle input line wakeup (wake = 0) ? in this wakeup method, an idle condition on the rxd pin clears the rwu bit and wakes up the sci. the initial frame or frames of every message contain addressing information. all receivers evaluate the addressing information, and receivers for which the message is addressed process the frames that follow. any receiver for which a message is not addressed can set its rwu bit and return to the standby state. the rwu bit remains set and the receiver remains on standby until another idle character appears on the rxd pin. idle line wakeup requires that messages be separated by at least one idle character and that no message contains idle characters. the idle character that wakes a receiver does not set the receiver idle flag, idle, or the receive data register full flag, rdrf. the idle line type bit, ilt, determines whether the receiver begins counting logic 1s as idle character bits after the start bit or after the stop bit. ilt is in sci control register 1 (sccr1).  address mark wakeup (wake = 1) ? in this wakeup method, a logic 1 in the most significant bit (msb) position of a frame clears the rwu bit and wakes up the sci. the logic 1 in the msb position marks a frame as an address frame that contains addressing information. all receivers evaluate the addressing information, and the receivers for which the message is addressed process the frames that follow. any receiver for which a message is not addressed can set its rwu bit and return to the standby state. the rwu bit remains set and the receiver remains on standby until another address frame appears on the rxd pin. the logic 1 msb of an address frame clears the receiver ? s rwu bit before the stop bit is received and sets the rdrf flag. address mark wakeup allows messages to contain idle characters but requires that the msb be reserved for use in address frames. note: with the wake bit clear, setting the rwu bit after the rxd pin has been idle can cause the receiver to wake up immediately.
serial communications interface module (sci) functional description advance information MC68HC812A4 ? rev. 5.0 motorola serial communications interface module (sci) 247 14.6.5 single-wire operation normally, the sci uses two pins for transmitting and receiving. in single-wire operation, the rxd pin is disconnected from the sci and is available as a general-purpose i/o pin. the sci uses the txd pin for both receiving and transmitting. setting the data direction bit for the txd pin configures txd as the output for transmitted data. clearing the data direction bit configures txd as the input for received data. figure 14-15. single-wire operation (loops = 1 and rsrc = 1) enable single-wire operation by setting the loops bit and the receiver source bit, rsrc, in sci control register 1 (sccr1). setting the loops bit disables the path from the rxd pin to the receiver. setting the rsrc bit connects the receiver input to the output of the txd pin driver. both the transmitter and receiver must be enabled (te = 1 and re = 1). the wired-or mode select bit, woms, configures the txd pin for full cmos drive or for open-drain drive. woms controls the txd pin in both normal operation and in single-wire operation. when woms is set, the data direction bit for the txd pin does not have to be cleared for txd to receive data. txd rxd transmitter receiver woms ddrs bit = 1 ddrs bit = 0 general- purpose i/o txd rxd transmitter receiver general- purpose i/o nc
MC68HC812A4 ? rev. 5.0 advance information 248 serial communications interface module (sci) motorola serial communications interface module (sci) 14.6.6 loop operation in loop operation, the transmitter output goes to the receiver input. the rxd pin is disconnected from the sci and is available as a general-purpose i/o pin. setting the data direction bit for the txd pin connects the transmitter output to the txd pin. clearing the data direction bit disconnects the transmitter output from the txd pin. figure 14-16. loop operation (loop = 1 and rsrc = 0) enable loop operation by setting the loops bit and clearing the rsrc bit in sci control register 1 (sccr1). setting the loops bit disables the path from the rxd pin to the receiver. clearing the rsrc bit connects the transmitter output to the receiver input. both the transmitter and receiver must be enabled (te = 1 and re = 1). the wired-or mode select bit, woms, configures the txd pin for full cmos drive or for open-drain drive. woms controls the txd pin in both normal operation and in loop operation. 14.7 register descriptions and reset initialization this section provides register descriptions and reset initialization. txd rxd woms ddrs bit = 1 ddrs bit = 0 general- purpose i/o txd rxd woms general- purpose i/o h transmitter receiver transmitter receiver
serial communications interface module (sci) register descriptions and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola serial communications interface module (sci) 249 14.7.1 sci baud rate registers read: anytime write: sbr[12:0] anytime; btst, bspl, and brld only in special modes btst ? reserved for test function bspl ? reserved for test function brld ? reserved for test function sbr[12:0] ? sci baud rate bits the value written to sbr[12:0] determines the baud rate of the sci. the new value takes effect when the low order byte is written. the formula for calculating baud rate is: br = value written to sbr[12:0], a value from 1 to 8191 note: the baud rate generator is disabled until the te bit or the re bit is set for the first time after reset. the baud rate generator is disabled when br = 0. sci0: $00c0 sci1: $00c8 bit 7654321bit 0 read: btst bspl brld sbr12 sbr11 sbr10 sbr9 sbr8 write: reset:00000000 figure 14-17. sci baud rate register high (sc0bdh or sc1bdh) sci0: $00c1 sci1: $00c9 bit 7654321bit 0 read: sbr7 sbr6 sbr5 sbr4 sbr3 sbr2 sbr1 sbr0 write: reset:00000100 figure 14-18. sci baud rate register low (sc0bdl or sc1bdl) sci baud rate mclk 16 br --------------------- =
MC68HC812A4 ? rev. 5.0 advance information 250 serial communications interface module (sci) motorola serial communications interface module (sci) 14.7.2 sci control register 1 read: anytime write: anytime loops ? loop select bit loops enables loop operation. in loop operation the rxd pin is disconnected from the sci, and the transmitter output goes into the receiver input. both the transmitter and the receiver must be enabled to use the loop function. 1 = loop operation enabled 0 = normal operation enabled the receiver input is determined by the rsrc bit. the transmitter output is controlled by the associated ddrs bit. if the data direction bit for the txd pin is set and loops = 1, the transmitter output appears on the txd pin. if the ddrs bit is clear and loops = 1, the txd pin is idle (high) if rsrc = 0 and high-impedance if rsrc = 1. see table 14-7 . woms ? wired-or mode select bit woms configures the txd and rxd pins for open-drain operation. woms allows txd pins to be tied together in a multiple-transmitter system. then the txd pins of non-active transmitters follow the logic level of an active 1. woms also affects the txd and rxd pins when they are general-purpose outputs. external pullup resistors are necessary on open-drain outputs. 1 = txd and rxd pins, open-drain when outputs 0 = txd and rxd pins, full cmos drive capability sci0: $00c2 sci1: $00ca bit 7654321bit 0 read: loops woms rsrc m wake ilt pe pt write: reset:00000000 figure 14-19. sci control register 1 (sc0cr1 or sc1cr1)
serial communications interface module (sci) register descriptions and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola serial communications interface module (sci) 251 rsrc ? receiver source bit when loops = 1, the rsrc bit determines the internal feedback path for the receiver. 1 = receiver input connected to txd pin 0 = receiver input internally connected to transmitter output m ? mode bit m determines whether data characters are eight or nine bits long. 1 = one start bit, nine data bits, one stop bit 0 = one start bit, eight data bits, one stop bit wake ? wakeup bit wake determines which condition wakes up the sci: a logic 1 (address mark) in the most significant bit position of a received data character or an idle condition on the rxd pin. 1 = address mark wakeup 0 = idle line wakeup table 14-7. loop mode functions loops rsrc ddrsx (1) woms function of txd pin 0xxx normal operation 100x loop mode; transmitter output connected to receiver input txd pin disconnected 1010 loop mode; transmitter output connected to receiver input txd is cmos output 1011 loop mode; transmitter output connected to receiver input txd is open-drain output 110x single-wire mode; transmitter output disconnected txd is high-impedance receiver input 1 1 1 0 single-wire mode; txd pin connected to receiver input 1111 single wire mode; txd pin connected to receiver input txd is open-drain for receiving and transmitting 1. ddrsx means the data direction bit of the txd pin.
MC68HC812A4 ? rev. 5.0 advance information 252 serial communications interface module (sci) motorola serial communications interface module (sci) ilt ? idle line type bit ilt determines when the receiver starts counting logic 1s as idle character bits. the counting begins either after the start bit or after the stop bit. if the count begins after the start bit, then a string of logic 1s preceding the stop bit may cause false recognition of an idle character. beginning the count after the stop bit avoids false idle character recognition, but requires properly synchronized transmissions. 1 = idle character bit count begins after stop bit. 0 = idle character bit count begins after start bit. pe ? parity enable bit pe enables the parity function. when enabled, the parity function inserts a parity bit in the most significant bit position. 1 = parity function enabled 0 = parity function disabled pt ? parity type bit pt determines whether the sci generates and checks for even parity or odd parity. with even parity, an even number of 1s clears the parity bit and an odd number of 1s sets the parity bit. with odd parity, an odd number of 1s clears the parity bit and an even number of 1s sets the parity bit. 1 = odd parity 0 = even parity 14.7.3 sci control register 2 read: anytime write: anytime sci0: $00c3 sci1: $00cb bit 7654321bit 0 read: tie tcie rie ilie te re rwu sbk write: reset:00000000 figure 14-20. sci control register 2 (sc0cr2 or sc1cr2)
serial communications interface module (sci) register descriptions and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola serial communications interface module (sci) 253 tie ? transmitter interrupt enable bit tie enables the transmit data register empty flag, tdre, to generate interrupt requests. 1 = tdre interrupt requests enabled 0 = tdre interrupt requests disabled tcie ? transmission complete interrupt enable bit tcie enables the transmission complete flag, tc, to generate interrupt requests. 1 = tc interrupt requests enabled 0 = tc interrupt requests disabled rie ? receiver interrupt enable bit rie enables the receive data register full flag, rdrf, and the overrun flag, or, to generate interrupt requests. 1 = rdrf and or interrupt requests enabled 0 = rdrf and or interrupt requests disabled ilie ? idle line interrupt enable bit ilie enables the idle line flag, idle, to generate interrupt requests. 1 = idle interrupt requests enabled 0 = idle interrupt requests disabled te ? transmitter enable bit te enables the sci transmitter and configures the txd pin as the sci transmitter output. the te bit can be used to queue an idle preamble. 1 = transmitter enabled 0 = transmitter disabled re ? receiver enable bit re enables the sci receiver. 1 = receiver enabled 0 = receiver disabled rwu ? receiver wakeup bit 1 = standby state 0 = normal operation
MC68HC812A4 ? rev. 5.0 advance information 254 serial communications interface module (sci) motorola serial communications interface module (sci) rwu enables the wakeup function and inhibits further receiver interrupt requests. normally, hardware wakes the receiver by automatically clearing rwu. sbk ? send break bit toggling sbk sends one break character (10 or 11 logic 0s). as long as sbk is set, the transmitter sends logic 0s. 1 = transmit break characters 0 = no break characters 14.7.4 sci status register 1 read: anytime write: has no meaning or effect tdre ? transmit data register empty flag tdre is set when the transmit shift register receives a byte from the sci data register. clear tdre by reading sci status register 1 with tdre set and then writing to the low byte of the sci data register. 1 = transmit data register empty 0 = transmit date register not empty tc ? transmission complete flag tc is set when the tdre flag is set and no data, preamble, or break character is being transmitted. when tc is set, the txd pin becomes idle (logic 1). clear tc by reading sci status register 1 with tc set sci0: $00c4 sci1: $00cc bit 7654321bit 0 read: tdre tc rdrf idle or nf fe pf write: reset:11000000 = unimplemented figure 14-21. sci status register 1 (sc0sr1 or sc1sr1)
serial communications interface module (sci) register descriptions and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola serial communications interface module (sci) 255 and then writing to the low byte of the sci data register. tc clears automatically when a break, preamble, or data is queued and ready to be sent. 1 = transmission complete 0 = transmission in progress rdrf ? receive data register full flag rdrf is set when the data in the receive shift register transfers to the sci data register. clear rdrf by reading sci status register 1 with rdrf set and then reading the low byte of the sci data register. 1 = receive data register full 0 = data not available in sci data register idle ? idle line flag idle is set when 10 consecutive logic 1s (if m = 0) or 11 consecutive logic 1s (if m = 1) appear on the receiver input. clear idle by reading sci status register 1 with idle set and then writing to the low byte of the sci data register. once idle is cleared, a valid frame must again set the rdrf flag before an idle condition can set the idle flag. 1 = receiver input has become idle 0 = receiver input is either active now or has never become active since the idle flag was last cleared note: when the receiver wakeup bit (rwu) is set, an idle line condition does not set the idle flag. or ? overrun flag or is set when software fails to read the sci data register before the receive shift register receives the next frame. the data in the shift register is lost, but the data already in the sci data registers is not affected. clear or by reading sci status register 1 with or set and then reading the low byte of the sci data register. 1 = overrun 0 = no overrun
MC68HC812A4 ? rev. 5.0 advance information 256 serial communications interface module (sci) motorola serial communications interface module (sci) nf ? noise flag nf is set when the sci detects noise on the receiver input. nf is set during the same cycle as the rdrf flag but does not get set in the case of an overrun. clear nf by reading sci status register 1 and then reading the low byte of the sci data register. 1 = noise 0 = no noise fe ? framing error flag fe is set when a logic 0 is accepted as the stop bit. fe is set during the same cycle as the rdrf flag but does not get set in the case of an overrun. fe inhibits further data reception until it is cleared. clear fe by reading sci status register 1 with fe set and then reading the low byte of the sci data register. 1 = framing error 0 = no framing error pf ? parity error flag pf is set when the parity enable bit, pe, is set and the parity of the received data does not match its parity bit. clear pf by reading sci status register 1 and then reading the low byte of the sci data register. 1 = parity error 0 = no parity error 14.7.5 sci status register 2 read: anytime write: has no meaning or effect sci0: $00c5 sci1: $00cd bit 7654321bit 0 read: 0 0 00000raf write: reset:00000000 = unimplemented figure 14-22. sci status register 2 (sc0sr2 or sc1sr2)
serial communications interface module (sci) register descriptions and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola serial communications interface module (sci) 257 raf ? receiver active flag raf is set when the receiver detects a logic 0 during the rt1 time period of the start bit search. raf is cleared when the receiver detects false start bits (usually from noise or baud rate mismatch) or when the receiver detects an idle character. 1 = reception in progress 0 = no reception in progress 14.7.6 sci data registers read: anytime; reading accesses receive data register write: anytime; writing accesses transmit data register; writing to r8 has no effect sci0: $00c6 sci1: $00ce bit 7654321bit 0 read: r8 t8 000000 write: reset: unaffected by reset = unimplemented figure 14-23. sci data register high (sc0drh or sc1drh) sci0: $00c7 sci1: $00cf bit 7654321bit 0 read: r7 r6 r5 r4 r3 r2 r1 r0 write: t7 t6 t5 t4 t3 t2 t1 t0 reset: unaffected by reset figure 14-24. sci data register low (sc0drl or sc1drl)
MC68HC812A4 ? rev. 5.0 advance information 258 serial communications interface module (sci) motorola serial communications interface module (sci) r8 ? received bit 8 r8 is the ninth data bit received when the sci is configured for 9-bit data format (m = 1). t8 ? transmitted bit 8 t8 is the ninth data bit transmitted when the sci is configured for 9-bit data format (m = 1). r7 ? r0 ? received bits 7 ? 0 t7 ? t0 ? transmitted bits 7 ? 0 note: if the value of t8 is the same as in the previous transmission, t8 does not have to be rewritten. the same value is transmitted until t8 is rewritten. in 8-bit data format, only sci data register low (scdrl) needs to be accessed. when transmitting in 9-bit data format and using 8-bit write instructions, write first to sci data register high (scdrh). 14.8 external pin descriptions this section provides a description of txd and rxd, the sci ? s two external pins. 14.8.1 txd pin txd is the sci transmitter pin. txd is available for general-purpose i/o when it is not configured for transmitter operation. 14.8.2 rxd pin rxd is the sci receiver pin. rxd is available for general-purpose i/o when it is not configured for receiver operation.
serial communications interface module (sci) modes of operation advance information MC68HC812A4 ? rev. 5.0 motorola serial communications interface module (sci) 259 14.9 modes of operation the sci functions the same in normal, special, and emulation modes. 14.10 low-power options this section provides a description of the three low-power modes:  run mode  wait mode  stop mode 14.10.1 run mode clearing the transmitter enable or receiver enable bits (te or re) in sci control register 2 (sccr2) reduces power consumption in run mode. sci registers are still accessible when te or re is cleared, but clocks to the core of the sci are disabled. 14.10.2 wait mode the sci remains active in wait mode. any enabled interrupt request from the sci can bring the mcu out of wait mode. if sci functions are not required during wait mode, reduce power consumption by disabling the sci before executing the wait instruction. 14.10.3 stop mode for reduced power consumption, the sci is inactive in stop mode. the stop instruction does not affect sci register states. sci operation resumes after an external interrupt. exiting stop mode by reset aborts any transmission or reception in progress and resets the sci.
MC68HC812A4 ? rev. 5.0 advance information 260 serial communications interface module (sci) motorola serial communications interface module (sci) 14.11 interrupt sources 14.12 general-purpose i/o ports port s shares its pins with the multiple serial interface (msi). in all modes, port s pins ps7 ? ps0 are available for either general-purpose i/o or for sci and spi functions. see section 13. multiple serial interface (msi) . 14.13 serial character transmission using the sci code is intended to use sci1 to serially transmit characters using polling to the lcd display on the udlp1 board: when the transmission data register is empty a flag will get set, which is telling us that sc1dr is ready so we can write another byte. the transmission is performed at a baud rate of 9600. since the sci1 is only being used for transmit data, the data register will not be used bidirectionally for received data. 14.13.1 equipment for this exercise, use the m68hc812a4evb emulation board. table 14-8. sci interrupt sources interrupt source flag local enable ccr mask vector address sci0 sci1 transmit data register empty tdre tie i bit $ffd6, $ffd7 $ffd4, $ffd5 transmission complete tc tcie i bit receive data register full rdrf rie i bit receiver overrun or receiver idle idle ilie i bit
serial communications interface module (sci) serial character transmission using the sci advance information MC68HC812A4 ? rev. 5.0 motorola serial communications interface module (sci) 261 14.13.2 code listing note: a comment line is delimited by a semicolon. if there is no code before comment, a semicolon ( ;) must be placed in the first column to avoid assembly errors. include ? equates.asm ? ; equates for registers ; user variables ; bit equates ; ---------------------------------------------------------------------- ; main program ; ---------------------------------------------------------------------- org $7000 ; 16k on-board ram, user code data area, ; ; start main program at $4000 main: bsr init ; subroutine to initialize sci0 registers bsr trans ; subroutine to start transmission done: bra done ; always branch to done, convenient for breakpoint ; ---------------------------------------------------------------------- ; subroutine init: ; ---------------------------------------------------------------------- init: tpa ; transfer ccr to a accumulator oraa #$10 ; ored a with #$10 to set i bit tap ; transfer a to ccr movb #$34,sc1bdl ; set baud =9600, in sci1 baud rate reg. movb #$00,sc1cr1 ; initialize for 8-bit data format, ; ; loop mode and parity disabled,(sc1cr1) movb #$08,sc1cr2 ; set for no ints, and transmitter enabled(sc1cr2) ldaa sc1sr1 ; 1st step to clear tdre flag: read sc1sr1 std sc1drh ; 2nd step to clear tdre flag: write sc1dr register ldx #data ; use x as a pointer to data. rts ; return from subroutine ; ---------------------------------------------------------------------- ; transmit subroutine ; ---------------------------------------------------------------------- trans: brclr sc1sr1,#$80, trans ; wait for tdre flag movb 1,x+,sc1drl ; transmit character, increment x pointer cpx #eot ; detect if last character has been transmitted bne trans ; if last char. not equal to "eot", branch to trans rts ; else transmission complete, return from subroutine ; ---------------------------------------------------------------------- ; table : data to be transmitted ; ---------------------------------------------------------------------- data: dc.b ? motorola hc12 banner - june, 1999 ? dc.b $0d,$0a ; return (cr) ,line feed (lf) dc.b ? scottsdale, arizona ? dc.b $0d,$0a ; return (cr) ,line feed (lf) eot: dc.b $04 ; byte used to test end of data = eot end ; end of program
MC68HC812A4 ? rev. 5.0 advance information 262 serial communications interface module (sci) motorola serial communications interface module (sci)
advance information MC68HC812A4 ? rev. 5.0 motorola serial peripheral interface (spi) 263 advance information ? MC68HC812A4 section 15. serial peripheral interface (spi) 15.1 contents 15.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .264 15.3 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .264 15.4 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .265 15.5 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .266 15.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .266 15.6.1 master mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .267 15.6.2 slave mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .268 15.6.3 baud rate generation . . . . . . . . . . . . . . . . . . . . . . . . . . . .268 15.6.4 clock phase and polarity . . . . . . . . . . . . . . . . . . . . . . . . . .268 15.6.5 ss output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .271 15.6.6 single-wire operation . . . . . . . . . . . . . . . . . . . . . . . . . . . .272 15.7 spi register descriptions and reset initialization . . . . . . . . .273 15.7.1 spi control register 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 15.7.2 spi control register 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 15.7.3 spi baud rate register . . . . . . . . . . . . . . . . . . . . . . . . . . .276 15.7.4 spi status register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .277 15.7.5 spi data register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .278 15.8 external pins. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .279 15.8.1 miso (master in, slave out) . . . . . . . . . . . . . . . . . . . . . . .279 15.8.2 mosi (master out, slave in) . . . . . . . . . . . . . . . . . . . . . . .279 15.8.3 sck (serial clock) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .279 15.8.4 ss (slave select) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .280 15.9 low-power options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .280 15.9.1 run mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .280 15.9.2 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .280 15.9.3 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .281 15.10 interrupt sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .281 15.11 general-purpose i/o ports . . . . . . . . . . . . . . . . . . . . . . . . . . .281
MC68HC812A4 ? rev. 5.0 advance information 264 serial peripheral interface (spi) motorola serial peripheral interface (spi) 15.12 synchronous character transmission using the spi. . . . . . .282 15.12.1 equipment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .282 15.12.2 code listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .282 15.2 introduction the serial peripheral interface (spi) allows full-duplex, synchronous, serial communications with peripheral devices. 15.3 features features of the spi include:  full-duplex operation  master mode and slave mode  programmable slave-select output option  programmable bidirectional data pin option  two flags with interrupt-generation capability: ? transmission complete ? mode fault  write collision detection  read data buffer  serial clock with programmable polarity and phase  reduced drive control for lower power consumption  programmable open-drain output option
serial peripheral interface (spi) block diagram advance information MC68HC812A4 ? rev. 5.0 motorola serial peripheral interface (spi) 265 15.4 block diagram figure 15-1. spi block diagram mosi or momi miso or siso sck ss interrupt baud rate divider clock clock logic cpha cpol spi lsbf ssoe swom modf wcol spif spc0 rds spe mstr control pups spr0 spr2 spr1 p-clock shift register port s data direction register port s data register 7 spie mstr request 654 shift control logic spi data register (write) spi data register (read) select pin control logic
MC68HC812A4 ? rev. 5.0 advance information 266 serial peripheral interface (spi) motorola serial peripheral interface (spi) 15.5 register map note: the register block can be mapped to any 2-kbyte boundary within the standard 64-kbyte address space. the register block occupies the first 512 bytes of the 2-kbyte block. this register map shows default addressing after reset. 15.6 functional description the spi allows full-duplex, synchronous, serial communication between the mcu and peripheral devices, including other mcus. in master mode, the spi generates the synchronizing clock and initiates transmissions. in addr.register name bit 7654321bit 0 $00d0 spi 0 control register 1 (sp0cr1) see page 273. read: spie spe swom mstr cpol cpha ssoe lsbf write: reset:00000100 $00d1 spi 0 control register 2 (sp0cr2) see page 275. read: 0000 pups rds 0 spc0 write: reset:00001000 $00d2 spi baud rate register (sp0br) see page 276. read: 00000 spr2 spr1 spr0 write: reset:00000000 $00d3 spi status register (sp0sr) see page 277. read: spif wcol 0 modf 0 0 0 0 write: reset:00000000 $00d5 spi data register (sp0dr) see page 278. read: bit 76543210 write: reset: unaffected by reset $00d6 port s data register (ports) see page 219. read: ps7 ps6 ps5 ps4 ps3 ps2 ps1 ps0 write: reset: unaffected by reset $00d7 port s data direction register (ddrs) see page 220. read: ddrs7 ddrs6 ddrs5 ddrs4 ddrs3 ddrs2 ddrs1 ddrs0 write: reset:00000000 = unimplemented figure 15-2. spi register map
serial peripheral interface (spi) functional description advance information MC68HC812A4 ? rev. 5.0 motorola serial peripheral interface (spi) 267 slave mode, the spi depends on a master peripheral to start and synchronize transmissions. 15.6.1 master mode the spi operates in master mode when the master mode bit, mstr, is set. note: configure spi modules as master or slave before enabling them. enable the master spi before enabling the slave spi. disable the slave spi before disabling the master spi. only a master spi module can initiate transmissions. begin the transmission from a master spi module by writing to the spi data register. if the shift register is empty, the byte immediately transfers to the shift register. the byte begins shifting out on the master out, slave in pin (mosi) under the control of the serial clock. see figure 15-3 . as the byte shifts out on the mosi pin, a byte shifts in from the slave on the master in, slave out pin (miso) pin. on the eighth serial clock cycle, the transmission ends and sets the spi flag, spif. at the same time that spif becomes set, the byte from the slave transfers from the shift register to the spi data register. the byte remains in a read buffer until replaced by the next byte from the slave. figure 15-3. full-duplex master/slave connections shift register shift register clock divider master mcu slave mcu v dd mosi mosi miso miso sck sck ss ss
MC68HC812A4 ? rev. 5.0 advance information 268 serial peripheral interface (spi) motorola serial peripheral interface (spi) 15.6.2 slave mode the spi operates in slave mode when mstr is clear. in slave mode, the sck pin is the input for the serial clock from the master. note: before a transmission occurs, the ss pin of the slave spi must be at logic 0. the slave ss pin must remain low until the transmission is complete. a transmission begins when initiated by a master spi. the byte from the master spi begins shifting in on the slave mosi pin under the control of the master serial clock. as the byte shifts in on the mosi pin, a byte shifts out on the miso pin to the master shift register. on the eighth serial clock cycle, the transmission ends and sets the spi flag, spif. at the same time that spif becomes set, the byte from the master transfers to the spi data register. the byte remains in a read buffer until replaced by the next byte from the master. 15.6.3 baud rate generation a clock divider in the spi produces eight divided p-clock signals. the p-clock divisors are 2, 4, 8, 16, 32, 64, 128, and 256. the spr[2:1:0] bits select one of the divided p-clock signals to control the rate of the shift register. through the sck pin, the selected clock signal also controls the rate of the shift register of the slave spi or other slave peripheral. the clock divider is active only in master mode and only when a transmission is taking place. otherwise, the divider is disabled to save power. 15.6.4 clock phase and polarity the clock phase and clock polarity bits, cpha and cpol, can select any of four combinations of serial clock phase and polarity. the cpha bit determines whether a falling ss edge or the first sck edge begins the transmission. the cpol bit determines whether sck is active-high or active-low.
serial peripheral interface (spi) functional description advance information MC68HC812A4 ? rev. 5.0 motorola serial peripheral interface (spi) 269 note: to transmit between spi modules, both modules must have identical cpha and cpol values. when cpha = 0, a falling ss edge signals the slave to begin transmission. the capture strobe for the first bit occurs on the first serial clock edge. therefore, the slave must begin driving its data before the first serial clock edge. after transmission of all eight bits, the slave ss pin must toggle from low to high to low again to begin another transmission. this format may be preferable in systems having more than one slave driving the master miso line. figure 15-4. transmission format 0 (cpha = 0) figure 15-5. slave ss toggling when cpha = 0 sck sck mosi miso ss capture strobe to slave cpol = 0 cpol = 1 end from master from slave sck cycles 1 2 3 4 5 6 7 8 t t t i t l begin transfer transfer msb first (lsbf = 0) lsb first (lsbf = 1) msb bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 lsb msb bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 lsb minimum t l , t t , and t i = 1/2 sck cycle byte 1 byte 3 miso/mosi byte 2 master ss slave ss cpha = 0
MC68HC812A4 ? rev. 5.0 advance information 270 serial peripheral interface (spi) motorola serial peripheral interface (spi) when cpha = 1, the master begins driving its mosi pin and the slave begins driving its miso pin on the first serial clock edge. the ss pin can remain low between transmissions. this format may be preferable in systems having only one slave driving the master miso line. note: the slave sck pin must be in the proper idle state before the slave is enabled. figure 15-6. transmission format 1 (cpha = 1) figure 15-7. slave ss when cpha = 1 sck sck mosi miso ss capture strobe to slave cpol = 0 cpol = 1 end from master from slave sck cycles 1 2 3 4 5 6 7 8 t t t i t l begin transfer transfer msb first (lsbf = 0) lsb first (lsbf = 1) msb bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 lsb msb bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 lsb minimum t l , t t , and t i = 1/2 sck cycle byte 1 byte 3 miso/mosi byte 2 master ss slave ss cpha = 1
serial peripheral interface (spi) functional description advance information MC68HC812A4 ? rev. 5.0 motorola serial peripheral interface (spi) 271 15.6.5 ss output in master mode only, the ss pin can function as a chip-select output for connection to the ss input of a slave. the master ss output automatically selects the slave by going low for each transmission and deselects the slave by going high during each idling state. enable the ss output by setting the master mode bit, mstr, the slave-select output enable bit, ssoe, and the data direction bit of the ss pin. mstr and ssoe are in spi control register 1. table 15-1. ss pin configurations control bits ss pin function ddrs7 ssoe master mode slave mode 0 0 slave-select input with mode-fault detection slave-select input 01 reserved 1 0 general-purpose output 1 1 slave-select output
MC68HC812A4 ? rev. 5.0 advance information 272 serial peripheral interface (spi) motorola serial peripheral interface (spi) 15.6.6 single-wire operation normally, the spi operates as a 2-wire interface; it uses its mosi and miso pins for transmitting and receiving. in single-wire operation, a master spi uses the mosi pin for both receiving and transmitting. the mosi pin becomes a master out, master in (momi) pin. the miso pin is disconnected from the spi and is available as a general-purpose port s i/o pin. a slave spi in single-wire operation uses the miso pin for both receiving and transmitting. the miso pin becomes a slave in, slave out (siso) pin. the mosi pin is disconnected from the spi and is available as a general-purpose i/o pin. setting serial pin control bit 0, spc0, configures the spi for single-wire operation. the direction of the single-wire pin depends on its data direction bit. figure 15-8. single-wire operation (spc0 = 1) spi momi ps4 serial out serial in ddrs5 spi ps5 siso ddrs4 serial in serial out master mode slave mode general- purpose i/o general- purpose i/o
serial peripheral interface (spi) spi register descriptions and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola serial peripheral interface (spi) 273 15.7 spi register descriptions and reset initialization this section describes the spi registers and reset initialization. 15.7.1 spi control register 1 read: anytime write: anytime spie ? spi interrupt enable bit spie enables the spif and modf flags to generate interrupt requests. 1 = spif and modf interrupt requests enabled 0 = spif and modf interrupt requests disabled spe ? spi enable bit setting the spe bit enables the spi and configures port s pins 7 ? 4 for spi functions. clearing spe puts the spi in a disabled, low-power state. 1 = spi enabled 0 = spi disabled note: when the modf flag is set, spe always reads as logic 0. writing to spi control register 1 is part of the mode fault recovery sequence. swom ? port s wired-or mode bit swom disables the pullup devices on port s pins 7 ? 4 so that they become open-drain outputs. 1 = open-drain port s pin 7 ? 4 outputs 0 = normal push-pull port s pin 7 ? 4 outputs address: $00d0 bit 7654321bit 0 read: spie spe swom mstr cpol cpha ssoe lsbf write: reset:00000100 figure 15-9. spi control register 1 (sp0cr1)
MC68HC812A4 ? rev. 5.0 advance information 274 serial peripheral interface (spi) motorola serial peripheral interface (spi) mstr ? master mode bit mstr selects master mode operation or slave mode operation. 1 = master mode 0 = slave mode cpol ? clock polarity bit cpol determines the logic state of the serial clock pin between transmissions. see figure 15-4 and figure 15-6 . 1 = active-high sck 0 = active-low sck cpha ? clock phase bit cpha determines whether transmission begins on the falling edge of the ss pin or on the first edge of the serial clock. see figure 15-4 and figure 15-6 . 1 = transmission at first sck edge 0 = transmission at falling ss edge ssoe ? slave select output enable bit ssoe enables the output function of master ss pin when the ddrs7 bit is also set. 1 = ss output enabled 0 = ss output disabled lsbf ? lsb first bit lsbf enables least-significant-bit-first transmissions. it does not affect the position of data in the spi data register; reads and writes of the spi data register always have the msb in bit 7. 1 = least-significant-bit-first transmission 0 = most-significant-bit-first transmission
serial peripheral interface (spi) spi register descriptions and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola serial peripheral interface (spi) 275 15.7.2 spi control register 2 read: anytime write: anytime pups ? pullup port s bit setting pups enables internal pullup devices on all port s input pins. if a pin is programmed as output, the pullup device becomes inactive. 1 = pullups enabled 0 = pullups disabled rds ? reduced drive port s bit setting rds lowers the drive capability of all port s output pins for lower power consumption and less noise. 1 = reduced drive 0 = normal drive spc0 ? serial pin control bit 0 spc0 enables single-wire operation of the mosi and miso pins. address: $00d1 bit 7654321bit 0 read: 0 0 0 0 pups rds 0 spc0 write: reset:00001000 = unimplemented figure 15-10. spi control register 2 (sp0cr2) table 15-2. single-wire operation control bits pins spc0 mstr ddrs5 ddrs4 mosi miso 1 1 0 1 ? master input master output general-purpose i/o 0 ? 0 1 general-purpose i/o slave input slave output
MC68HC812A4 ? rev. 5.0 advance information 276 serial peripheral interface (spi) motorola serial peripheral interface (spi) 15.7.3 spi baud rate register read: anytime write: anytime spr2 ? spr0 ? spi clock rate select bits these bits select one of eight spi baud rates as shown in table 15-3 . reset clears spr2 ? spr0, selecting e-clock divided by two. address: $00d2 bit 7654321bit 0 read: 0 0 0 0 0 spr2 spr1 spr0 write: reset:00000000 = unimplemented figure 15-11. spi baud rate register (sp0br) table 15-3. spi clock rate selection spr[2:1:0] e-clock divisor baud rate (e-clock = 4 mhz) baud rate (e-clock = 8 mhz) 000 2 2.0 mhz 4.0 mhz 001 4 1.0 mhz 2.0 mhz 010 8 500 khz 1.0 mhz 011 16 250 khz 500 khz 100 32 125 khz 250 khz 101 64 62.5 khz 125 khz 110 128 31.3 khz 62.5 khz 111 256 15.6 khz 31.3 khz
serial peripheral interface (spi) spi register descriptions and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola serial peripheral interface (spi) 277 15.7.4 spi status register read: anytime write: has no meaning or effect spif ? spi flag spif is set after the eighth serial clock cycle of a transmissson. spif generates an interrupt request if the spie bit in spi control register 1 is set also. clear spif by reading the spi status register with spif set and then reading or writing to the spi data register. 1 = transfer complete 0 = transfer not complete wcol ? write collision flag wcol is set when a write to the spi data register occurs during a data transfer. the byte being transferred continues to shift out of the shift register, and the data written during the transfer is lost. wcol does not generate an interrupt request. wcol can be read when the transfer in progress is complete. clear wcol by reading the spi status register with wcol set and then reading or writing to the spi data register. 1 = write collision 0 = no write collision address: $00d3 bit 7654321bit 0 read: spif wcol 0 modf 0000 write: reset:00000000 = unimplemented figure 15-12. spi status register (sp0sr)
MC68HC812A4 ? rev. 5.0 advance information 278 serial peripheral interface (spi) motorola serial peripheral interface (spi) modf ? mode fault flag modf is set if the ps7 pin goes to logic 0 when it is configured as the ss input of a master spi (mstr = 1 and ddr7 = 0). clear modf by reading the spi status register with modf set and then writing to spi control register 1. 1 = mode fault 0 = no mode fault note: modf is inhibited when the ps7 pin is configured as:  the ss output, ddrs7 = 1 and ssoe = 1, or  a general-purpose output, ddrs7 = 1 and ssoe = 0 15.7.5 spi data register read: anytime; normally, only after spif flag set write: anytime a data transfer is not taking place the spi data register is both the input and output register for spi data. reads are double-buffered but writes cause data to be written directly into the spi shift register. the data registers of two spis can be connected through their mosi and miso pins to form a distributed 16-bit register. a transmission between the spis shifts the data eight bit positions, exchanging the data between the master and the slave. the slave can also be another simpler device that only receives data from the master or that only sends data to the master. address: $00d5 bit 7654321bit 0 read: bit 7654321bit 0 write: reset: unaffected by reset figure 15-13. spi data register (sp0dr)
serial peripheral interface (spi) external pins advance information MC68HC812A4 ? rev. 5.0 motorola serial peripheral interface (spi) 279 15.8 external pins the spi module has four i/o pins:  miso ? master data in, slave data out  mosi ? master data out, slave data in  sck ? serial clock  ss ? slave select the spi has limited inter-integrated circuit (i 2 c) capability (requiring software support) as a master in a single-master environment. to communicate with i 2 c peripherals, mosi becomes an open-drain output when the swom bit in the spi control register is set. in i 2 c communication, the mosi and miso pins are connected to a bidirectional pin from the i 2 c peripheral and through a pullup resistor to v dd . 15.8.1 miso (master in, slave out) in a master spi, miso is the data input. in a slave spi, miso is the data output. in a slave spi, the miso output pin is enabled only when its ss pin is at logic 0. to support a multiple-slave system, a logic 1 on the ss pin of a slave puts the miso pin in a high-impedance state. 15.8.2 mosi (master out, slave in) in a master spi, mosi is the data output. in a slave spi, mosi is the data input. 15.8.3 sck (serial clock) the serial clock synchronizes data transmission between master and slave devices. in a master spi, the sck pin is the clock output to the slave. in a slave mcu, the sck pin is the clock input from the master.
MC68HC812A4 ? rev. 5.0 advance information 280 serial peripheral interface (spi) motorola serial peripheral interface (spi) 15.8.4 ss (slave select) the ss pin has multiple functions that depend on spi configuration:  the ss pin of a slave spi is always configured as an input and allows the slave to be selected for transmission.  when the cpha bit is clear, the ss pin signals the start of a transmission.  the ss pin of a master spi can be configured as a mode-fault input, a slave-select output, or a general-purpose output. ? as a mode-fault input (mstr = 1, ddrs7 = 0, ssoe = 0), the ss pin can detect multiple masters driving mosi and spsck. ? as a slave-select output (mstr = 1, ddrs7 = 1, ssoe = 1), the ss pin can select slaves for transmission. ? when mstr = 1, ddrs7 = 1, and ssoe = 0, the ss pin is available as a general-purpose output. 15.9 low-power options this section describes the three low-power modes:  run mode  wait mode  stop mode 15.9.1 run mode clearing the spi enable bit, spe, in spi control register 1 reduces power consumption in run mode. spi registers are still accessible when spe is cleared, but clocks to the core of the spi are disabled. 15.9.2 wait mode the spi remains active in wait mode. any enabled interrupt request from the spi can bring the mcu out of wait mode.
serial peripheral interface (spi) interrupt sources advance information MC68HC812A4 ? rev. 5.0 motorola serial peripheral interface (spi) 281 if spi functions are not required during wait mode, reduce power consumption by disabling the spi before executing the wait instruction. 15.9.3 stop mode for reduced power consumption, the spi is inactive in stop mode. the stop instruction does not affect spi register states. spi operation resumes after an external interrupt. exiting stop mode by reset aborts any transmission in progress and resets the spi. entering stop mode during a transmission results in invalid data. 15.10 interrupt sources 15.11 general-purpose i/o ports port s shares its pins with the multiple serial interface (msi). in all modes, port s pins ps7 ? ps0 are available for either general-purpose i/o or for sci and spi functions. see section 13. multiple serial interface (msi) . table 15-4. spi interrupt sources interrupt source flag local enable ccr mask vector address transmission complete spif spie i bit $ffd8, $ffd9 mode fault modf
MC68HC812A4 ? rev. 5.0 advance information 282 serial peripheral interface (spi) motorola serial peripheral interface (spi) 15.12 synchronous character transmission using the spi this program is intended to communicate with the hc11 on the udlp1 board. it utilizes the spi to transmit synchronously characters in a string to be displayed on the lcd display. the program must configure the spi as a master, and non-interrupt driven. the slave peripheral is chip-selected with the ss line at low voltage level. between 8 bit transfers the ss line is held high. also the clock idles low and takes data on the rising clock edges. the serial clock is set not to exceed 100 khz baud rate. 15.12.1 equipment for this exercise, use the m68hc812a4evb emulation board. 15.12.2 code listing note: a comment line is delimited by a semicolon. if there is no code before comment, a semicolon ( ;) must be placed in the first column to avoid assembly errors. include ? equates.asm ? ;equates for all registers ; user variables ; bit equates ; ---------------------------------------------------------------------- ; main program ; ---------------------------------------------------------------------- org $7000 ; 16k on-board ram, user code data area, ; ; start main program at $7000 main: bsr init ; subroutine to initialize spi registers bsr transmit ; subroutine to start transmission finish: bra finis ; finished transmitting all data
serial peripheral interface (spi) synchronous character transmission using the spi advance information MC68HC812A4 ? rev. 5.0 motorola serial peripheral interface (spi) 283 ; ---------------------------------------------------------------------- ;* subroutine init: ; ---------------------------------------------------------------------- init: bset ports,#$80 ; set ss line high to prevent glitch movb #$e0,ddrs ; configure port s input/ouput levels ; ; mosi, sck, ss* = ouput, miso=input movb #$07,sp0br ; select serial clock baud rate < 100 khz movb #$12,sp0cr1 ; configure spi(sp0cr1): no spi interrupts, ; ; mstr=1, cpol=0, cpha=0 movb #$08,sp0cr2 ; config. ports output drivers to operate normally, ; ; and with active pull-up devices. ldx #data ; use x register as pointer to first character ldaa sp0sr ; 1st step to clear spif flag, read sp0sr ldaa sp0dr ; 2nd step to clear spif flag, access sp0dr bset sp0cr1,#$40 ; enable the spi (spe=1) rts ; return from subroutine ; ---------------------------------------------------------------------- ;* transmit subroutine ; ---------------------------------------------------------------------- transmit: ldaa 1,x+ ; load acc. with "new" character to send, inc x beq done ; detect if last character(0) has been transmitted ; ; if last char. branch to done, else bclr ports,#$80 ; assert ss line to start x-misssion. staa sp0dr ; load data into data reg.,x-mit. ; ; it is also the 2nd step to clear spif flag. flag: brclr sp0sr,#$80,flag ;wait for flag. bset ports,#$80 ; disassert ss line. bra transmit ; continue sending characters, branch to transmit. done: rts ; return from subroutine ; ---------------------------------------------------------------------- ; table of data to be transmitted ; ---------------------------------------------------------------------- data: dc.b ? motorola ? dc.b $0d,$0a ; return (cr) ,line feed (lf) eot: dc.b $00 ; byte used to test end of data = eot end ; end of program
MC68HC812A4 ? rev. 5.0 advance information 284 serial peripheral interface (spi) motorola serial peripheral interface (spi)
advance information MC68HC812A4 ? rev. 5.0 motorola analog-to-digital converter (atd) 285 advance information ? MC68HC812A4 section 16. analog-to-digital converter (atd) 16.1 contents 16.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .286 16.3 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .286 16.4 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .287 16.5 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .288 16.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .290 16.7 registers and reset initialization . . . . . . . . . . . . . . . . . . . . . . 291 16.7.1 atd control register 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 16.7.2 atd control register 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 16.7.3 atd control register 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 16.7.4 adt control register 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 16.7.5 atd control register 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . 294 16.7.6 atd control register 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 16.7.7 atd status registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . .298 16.7.8 atd test registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .299 16.7.9 atd result registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300 16.8 low-power options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .301 16.8.1 run mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .301 16.8.2 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .301 16.8.3 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .301 16.9 interrupt sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .302 16.10 general-purpose ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .302 16.11 port ad data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .302 16.12 using the atd to measure a potentiometer signal . . . . . . . .303 16.12.1 equipment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .303 16.12.2 code listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .303
MC68HC812A4 ? rev. 5.0 advance information 286 analog-to-digital converter (atd) motorola analog-to-digital converter (atd) 16.2 introduction the analog-to-digital converter (atd) is an 8-channel, 8-bit, multiplexed-input, successive approximation analog-to-digital converter, accurate to 1 least significant bit (lsb). it does not require external sample and hold circuits because of the type of charge redistribution technique used. the atd converter timing can be synchronized to the system p-clock. the atd module consists of a 16-word (32-byte) memory-mapped control register block used for control, testing, and configuration. 16.3 features features of the atd module include:  eight multiplexed input channels  multiplexed-input successive approximation  8-bit resolution  single or continuous conversion  conversion complete flag with cpu interrupt request  selectable atd clock
analog-to-digital converter (atd) block diagram advance information MC68HC812A4 ? rev. 5.0 motorola analog-to-digital converter (atd) 287 16.4 block diagram figure 16-1. atd block diagram channel 0 sar rc dac array and comparator v dda v ssa v rl v rh analog mux and sample buffer amp an7/pad7 an6/pad6 an5/pad5 an4/pad4 an3/pad3 an2/pad2 an1/pad1 an0/pad0 channel 1 channel 2 channel 3 channel 4 channel 5 channel 6 channel 7 mode and timing control clock select/prescale port ad data input register
MC68HC812A4 ? rev. 5.0 advance information 288 analog-to-digital converter (atd) motorola analog-to-digital converter (atd) 16.5 register map note: the register block can be mapped to any 2-kbyte boundary within the standard 64-kbyte address space. the register block occupies the first 512 bytes of the 2-kbyte block. this register map shows default addressing after reset. addr.register name bit 7654321bit 0 $0060 atd control register 0 (atdctl0) see page 291. read: 00000000 write: reset:00000000 $0061 atd control register 1 (atdctl1) see page 291. read: 00000000 write: reset:00000000 $0062 atd control register 2 (atdctl2) see page 292. read: adpu affc awai 000 ascie ascif write: reset:00000000 $0063 atd control register 3 (atdctl3) see page 293. read: 000000 frz1 frz0 write: reset:00000000 $0064 atd control register 4 (atdctl4) see page 294. read: 0 smp1 smp0 prs4 prs3 prs2 prs1 prs0 write: reset:00000001 $0065 atd control register 5 (atdctl5) see page 296. read: 0 s8cm scan mult cd cc cb ca write: reset:00000000 $0066 atd status register 1 (atdstat1) see page 298. read: scf 0 0 0 0 cc2 cc1 cc0 write: reset:00000000 $0067 atd status register 2 (atdstat2) see page 298. read: ccf7 ccf6 ccf5 ccf4 ccf3 ccf2 ccf1 ccf0 write: reset:00000000 = unimplemented figure 16-2. atd i/o register summary (sheet 1 of 3)
analog-to-digital converter (atd) register map advance information MC68HC812A4 ? rev. 5.0 motorola analog-to-digital converter (atd) 289 $0068 atd test register 1 (atdtest1) see page 299. read: sar9 sar8 sar7 sar6 sar5 sar4 sar3 sar2 write: reset:00000000 $0069 atd test register 2 (atdtest2) see page 299. read: sar1 sar0 rst tstout tst3 tst2 tst1 tst0 write: reset:00000000 $006f port ad data input register (portad) see page 302. read: pad7 pad6 pad5 pad4 pad3 pad2 pad1 pad0 write: reset:00000000 $0070 atd result register 0 (adr0h) see page 300. read: adrxh7 adrxh6 adrxh5 adrxh4 adrxh3 adrxh2 adrxh1 adrxh0 write: reset: indeterminate $0072 atd result register 1 (adr1h) see page 300. read: adrxh7 adrxh6 adrxh5 adrxh4 adrxh3 adrxh2 adrxh1 adrxh0 write: reset: indeterminate $0074 atd result register 2 (adr2h) see page 300. read: adrxh7 adrxh6 adrxh5 adrxh4 adrxh3 adrxh2 adrxh1 adrxh0 write: reset: indeterminate $0076 atd result register 3 (adr3h) see page 300. read: adrxh7 adrxh6 adrxh5 adrxh4 adrxh3 adrxh2 adrxh1 adrxh0 write: reset: indeterminate $0078 atd result register 4 (adr4h) see page 300. read: adrxh7 adrxh6 adrxh5 adrxh4 adrxh3 adrxh2 adrxh1 adrxh0 write: reset: indeterminate $007a atd result register 5 (adr5h) see page 300. read: adrxh7 adrxh6 adrxh5 adrxh4 adrxh3 adrxh2 adrxh1 adrxh0 write: reset: indeterminate addr.register name bit 7654321bit 0 = unimplemented figure 16-2. atd i/o register summary (sheet 2 of 3)
MC68HC812A4 ? rev. 5.0 advance information 290 analog-to-digital converter (atd) motorola analog-to-digital converter (atd) 16.6 functional description a single conversion sequence consists of four or eight conversions, depending on the state of the select 8-channel mode bit, s8cm, in atd control register 5 (atdctl5). there are eight basic conversion modes. in the non-scan modes, the sequence complete flag, scf, is set after the sequence of four or eight conversions has been performed and the atd module halts. in the scan modes, the scf flag is set after the first sequence of four or eight conversions has been performed, and the atd module continues to restart the sequence. in both modes, the ccf flag associated with each register is set when that register is loaded with the appropriate conversion result. that flag is cleared automatically when that result register is read. the conversions are started by writing to the control registers. the atd control register 4 selects the clock source and sets up the prescaler. writes to the atd control registers initiate a new conversion sequence. if a write occurs while a conversion is in progress, the conversion is aborted and atd activity halts until a write to atdctl5 occurs. the atd control register 5 selects conversion modes and conversion channel(s) and initiates conversions. $007c atd result register 6 (adr6h) see page 300. read: adrxh7 adrxh6 adrxh5 adrxh4 adrxh3 adrxh2 adrxh1 adrxh0 write: reset: indeterminate $007e atd result register 7 (adr7h) see page 300. read: adrxh7 adrxh6 adrxh5 adrxh4 adrxh3 adrxh2 adrxh1 adrxh0 write: reset: indeterminate addr.register name bit 7654321bit 0 = unimplemented figure 16-2. atd i/o register summary (sheet 3 of 3)
analog-to-digital converter (atd) registers and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola analog-to-digital converter (atd) 291 a write to atdctl5 initiates a new conversion sequence. if a conversion sequence is in progress when a write occurs, the sequence is aborted and the scf and ccf flags are cleared. 16.7 registers and reset initialization this section describes the registers and reset initialization. 16.7.1 atd control register 0 note: writing to this register aborts the current conversion sequence. 16.7.2 atd control register 1 address: $0060 bit 7654321bit 0 read: 00000000 write: reset:00000000 figure 16-3. atd control register 0 (atdctl0) address: $0061 bit 7654321bit 0 read: 0 0 000000 write: reset:00000000 = unimplemented figure 16-4. atd control register 1 (atdctl1)
MC68HC812A4 ? rev. 5.0 advance information 292 analog-to-digital converter (atd) motorola analog-to-digital converter (atd) 16.7.3 atd control register 2 read: anytime write: anytime except ascif flag, which is read-only note: writing to this register aborts the current conversion sequence. adpu ? atd power-up bit adpu enables the clock signal to the atd and powers up its analog circuits. 1 = atd enabled 0 = atd disabled note: after adpu is set, the atd requires an analog circuit stabilization period. affc ? atd fast flag clear bit when affc is set, writing to a result register (adr0h ? adr7h) clears the associated ccf flag if it is set. when affc is clear, clearing a ccf flag requires a read of the status register followed by a read of the result register. 1 = fast ccf clearing enabled 0 = fast ccf clearing disabled awai ? atd stop in wait mode bit aswai disables the atd in wait mode for lower power consumption. 1 = atd disabled in wait mode 0 = atd enabled in wait mode address: $0062 bit 7654321bit 0 read: adpu affc awai 000 ascie ascif write: reset:00000000 = unimplemented figure 16-5. atd control register 2 (atdctl2)
analog-to-digital converter (atd) registers and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola analog-to-digital converter (atd) 293 ascie ? atd sequence complete interrupt enable bit ascie enables interrupt requests generated by the atd sequence complete interrupt flag, ascif. 1 = ascif interrupt requests enabled 0 = ascif interrupt requests disabled ascif ? atd sequence complete interrupt flag ascif is set when a conversion sequence is finished. if the atd sequence complete interrupt enable bit, ascie, is also set, ascif generates an interrupt request. 1 = conversion sequence complete 0 = conversion sequence not complete note: the ascif flag is set only when a conversion sequence is completed and ascie = 1 or interrupts on the analog-to-digital converter (atd) module are enabled. 16.7.4 adt control register 3 frz1 and frz0 ? freeze bits the frz bits suspend atd operation for background debugging. when debugging an application, it is useful in many cases to have the atd pause when a breakpoint is encountered. these two bits determine how the atd responds when background debug mode becomes active. see table 16-1 . address: $0063 bit 7654321bit 0 read: 0 0 0000 frz1 frz0 write: reset:00000000 = unimplemented figure 16-6. atd control register 3 (atdctl3)
MC68HC812A4 ? rev. 5.0 advance information 294 analog-to-digital converter (atd) motorola analog-to-digital converter (atd) 16.7.5 atd control register 4 smp1 and smp0 ? sample time select bits these bits select one of four sample times after the buffered sample and transfer has occurred. total conversion time depends on initial sample time (two atd clocks), transfer time (four atd clocks), final sample time (programmable, refer to table 16-2 ), and resolution time (10 atd clocks). table 16-1. atd response to background debug enable frz1:frz0 atd response 00 continue conversions in active background mode 01 reserved 10 finish current conversion, then freeze 11 freeze when bdm is active address: $0064 bit 7654321bit 0 read: 0 smp1 smp0 prs4 prs3 prs2 prs1 prs0 write: reset:00000001 = unimplemented figure 16-7. atd control register 4 (atdctl4) table 16-2. final sample time selection smp[1:0] final sample time total 8-bit conversion time 00 2 atd clock periods 18 atd clock periods 01 4 atd clock periods 20 atd clock periods 10 8 atd clock periods 24 atd clock periods 11 16 atd clock periods 32 atd clock periods
analog-to-digital converter (atd) registers and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola analog-to-digital converter (atd) 295 prs[4:0] ? prescaler select bits the prescaler divides the p-clock by the binary value written to prs[4:0] plus one. to assure symmetry of the prescaler output, an additional divide-by-two circuit generates the atd module clock. clearing prs[4:0] means the p-clock is divided only by the divide-by-two circuit. the reset state of prs[4:0] is 00001, giving a total p-clock divisor of four, which is appropriate for nominal operation at 2 mhz. table 16-3 shows the appropriate range of system clock frequencies for each p clock divisor. table 16-3. clock prescaler values prs[4:0] p-clock divisor max p-clock (1) 1. maximum conversion frequency is 2 mhz. maximum p-clock divisor value becomes max- imum conversion rate that can be used on this atd module. min p-clock (2) 2. minimum conversion frequency is 500 khz. minimum p-clock divisor value becomes min- imum conversion rate that this atd can perform. 00000 2 4 mhz 1 mhz 00001 4 8 mhz 2 mhz 00010 6 8 mhz 3 mhz 00011 8 8 mhz 4 mhz 00100 10 8 mhz 5 mhz 00101 12 8 mhz 6 mhz 00110 14 8 mhz 7 mhz 00111 16 8 mhz 8 mhz 01xxx do not use 1xxxx
MC68HC812A4 ? rev. 5.0 advance information 296 analog-to-digital converter (atd) motorola analog-to-digital converter (atd) 16.7.6 atd control register 5 read: anytime write: anytime s8cm ? select eight conversions mode bit s8cm selects conversion sequences of either eight or four conversions. 1 = eight conversion sequences 0 = four conversion sequences scan ? continuous channel scan bit scan selects a single conversion sequence or continuous conversion sequences. 1 = continuous conversion sequences (scan mode) 0 = single conversion sequence mult ? multichannel conversion bit refer to table 16-4 . 1 = conversions of sequential channels 0 = conversions of a single input channel selected by the cd, cc, cb, and ca bits cd, cc, cb, and ca ? channel select bits the channel select bits select the input to convert. lt = 1, the atd sequencer selects address: $0065 bit 7654321bit 0 read: 0 s8cm scan mult cd cc cb ca write: reset:00000000 = unimplemented figure 16-8. atd control register 5 (atdctl5)
analog-to-digital converter (atd) registers and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola analog-to-digital converter (atd) 297 table 16-4. multichannel mode result register assignment (1) 1. when mult = 1, bits with asterisks are don ? t care bits. the 4-conversion sequence from an0 to an3 or the 8-conversion sequence from an0 to an7 is completed in the order shown. when mult = 0, the cd, cc, cb, and ca bits select one input channel. the conversion sequence is performed on this channel only. s8cm cd cc cb ca channel input result in adrxh 00 0 0* 0* an0 adrxh0 0* 1* an1 adrxh1 1* 0* an2 adrxh2 1* 1* an3 adrxh3 1 0* 0* an4 adrxh0 0* 1* an5 adrxh1 1* 0* an6 adrxh2 1* 1* an7 adrxh3 01 0 0* 0* reserved adrxh0 0* 1* reserved adrxh1 1* 0* reserved adrxh2 1* 1* reserved adrxh3 1 0* 0* v rh adrxh0 0* 1* v rl adrxh1 1* 0* (v rh + v rl )/2 adrxh2 1* 1* test/reserved adrxh3 10 0* 0* 0* an0 adrxh0 0* 1* an1 adrxh1 1* 0* an2 adrxh2 1* 1* an3 adrxh3 1* 0* 0* an4 adrxh4 0* 1* an5 adrxh5 1* 0* an6 adrxh6 1* 1* an7 adrxh7 11 0* 0* 0* reserved adrxh0 0* 1* reserved adrxh1 1* 0* reserved adrxh2 1* 1* reserved adrxh3 1* 0* 0* v rh adrxh4 0* 1* v rl adrxh5 1* 0* (v rh + v rl )/2 adrxh6 1* 1* test/reserved adrxh7
MC68HC812A4 ? rev. 5.0 advance information 298 analog-to-digital converter (atd) motorola analog-to-digital converter (atd) 16.7.7 atd status registers read: anytime write: special mode only scf ? sequence complete flag in single conversion sequence mode (scan = 0 in atdctl5), scf is set at the end of the conversion sequence. in continuous conversion mode (scan = 1 in atdctl5), scf is set at the end of the first conversion sequence. clear scf by writing to control register 5 (atdctl5) to initiate a new conversion sequence. when the fast flag clear enable bit, affc, is set, scf is cleared after the first result register is read. cc2 ? cc0 ? conversion counter bits this 3-bit value reflects the value of the conversion counter pointer in either a 4-conversion or 8-conversion sequence. the pointer shows which channel is currently being converted and which result register will be written next. address: $0066 bit 7654321bit 0 read: scf 0 0 0 0 cc2 cc1 cc0 write: reset:00000000 = unimplemented figure 16-9. atd status register 1 (atdstat1) address: $0067 bit 7654321bit 0 read: ccf7 ccf6 ccf5 ccf4 ccf3 ccf2 ccf1 ccf0 write: reset:00000000 = unimplemented figure 16-10. atd status register 2 (atdstat2)
analog-to-digital converter (atd) registers and reset initialization advance information MC68HC812A4 ? rev. 5.0 motorola analog-to-digital converter (atd) 299 ccf7 ? ccf0 ? conversion complete flags each atd channel has a ccf flag. a ccf flag is set at the end of the conversion on that channel. clear a ccf flag by reading status register 1 with the flag set and then reading the result register of that channel. when the fast flag clear enable bit, affc, is set, reading the result register clears the associated ccf flag even if the status register has not been read. 16.7.8 atd test registers read: special modes only write: special modes only the test registers control various special modes which are used during manufacturing. in the normal modes, reads of the test register return 0 and writes have no effect. address: $0068 bit 7654321bit 0 read: sar9 sar8 sar7 sar6 sar5 sar4 sar3 sar2 write: reset:00000000 figure 16-11. atd test register 1 (atdtest1) address: $0069 bit 7654321bit 0 read: sar1 sar0 rst tstout tst3 tst2 tst1 tst0 write: reset:00000000 figure 16-12. atd test register 2 (atdtest2)
MC68HC812A4 ? rev. 5.0 advance information 300 analog-to-digital converter (atd) motorola analog-to-digital converter (atd) sar9 ? sar0 ? sar data bits reads of this byte return the current value in the sar. writes to this byte change the sar to the value written. bits sar9 ? sar2 reflect the eight sar bits used during the resolution process for an 8-bit result. sar1 and sar0 are reserved to allow future derivatives to increase atd resolution to 10 bits. rst ? reset bit when set, this bit causes all registers and activity in the module to assume the same state as out of power-on reset (except for adpu bit in atdctl2, which remains set, allowing the atd module to remain enabled). tstout ? multiplex output of tst3 ? tst0 (factory use) tst3 ? tst0 ? test bits 3 to 0 (reserved) selects one of 16 reserved factory testing modes 16.7.9 atd result registers read: anytime write: has no meaning or effect address: adr0h: $0070 adr1h: $0072 adr2h: $0074 adr3h: $0076 adr4h: $0078 adr5h: $007a adr6h: $007c adr7h: $007e bit 7654321bit 0 read: adrxh7 adrxh6 adrxh5 adrxh4 adrxh3 adrxh2 adrxh1 adrxh0 write: reset: indeterminate figure 16-13. atd result registers (adr0h ? adr7h)
analog-to-digital converter (atd) low-power options advance information MC68HC812A4 ? rev. 5.0 motorola analog-to-digital converter (atd) 301 adrxh7 ? adrxh0 ? atd conversion result bits these bits contain the left justified, unsigned result from the atd conversion. the channel from which this result was obtained depends on the conversion mode selected. these registers are always read-only in normal mode. 16.8 low-power options this section describes the three low-power modes:  run mode  wait mode  stop mode 16.8.1 run mode clearing the atd power-up bit, adpu, in atd control register 2 (atdctl2) reduces power consumption in run mode. atd registers are still accessible, but the clock to the atd is disabled and atd analog circuits are powered down. 16.8.2 wait mode atd operation in wait mode depends on the state of the atd stop in wait bit, awai, in atd control register 2 (atdctl2).  if awai is clear, the atd operates normally when the cpu is in wait mode  if awai is set, the atd clock is disabled and conversion continues unless aswai bit in atdctl2 register is set. 16.8.3 stop mode the atd is inactive in stop mode for reduced power consumption. the stop instruction aborts any conversion sequence in progress.
MC68HC812A4 ? rev. 5.0 advance information 302 analog-to-digital converter (atd) motorola analog-to-digital converter (atd) 16.9 interrupt sources note: the ascif flag is set only when a conversion sequence is completed and ascie = 1 or interrupts on the analog-to-digital converter (atd) module are enabled. 16.10 general-purpose ports port ad is an input-only port. when the atd is enabled, port ad is the analog input port for the atd. setting the atd power-up bit, adpu, in atd control register 2 enables the atd. port ad is available for general-purpose input when the atd is disabled. clearing the adpu bit disables the atd. 16.11 port ad data register read: anytime; reads return logic levels on the pad pins write: has no meaning or effect pad7 ? pad0 ? port ad data input bits table 16-5. spi interrupt sources interrupt source flag local enable ccr mask vector address conversion sequence complete ascif ascie i bit $ffd2, $ffd3 address: $006f bit 7654321bit 0 read: pad7 pad6 pad5 pad4 pad3 pad2 pad1 pad0 write: reset:00000000 = unimplemented figure 16-14. port ad data input register (portad)
analog-to-digital converter (atd) using the atd to measure a potentiometer signal advance information MC68HC812A4 ? rev. 5.0 motorola analog-to-digital converter (atd) 303 16.12 using the atd to measure a potentiometer signal this exercise allows the student to utilize the atd on the hc12 to measure a potentiometer signal output routed from the udlp1 board to the hc12 atd pin pad6. first the atdctl registers are initialized. a delay loop of 100 s is then executed. the resolution is set up followed by a conversion set up on channel 6. after waiting for the status bit to set, the result goes to the d accumulator. if the program is working properly, a different value should be found in the d accumulator as the left potentiometer is varied for each execution of the program. 16.12.1 equipment for this exercise, use the m68hc812a4evb emulation board. 16.12.2 code listing note: a comment line is delimited by a semicolon. if there is no code before comment, a semicolon (;) must be placed in the first column to avoid assembly errors. ; ---------------------------------------------------------------------- ; main program ; ---------------------------------------------------------------------- org $7000 ; 16k on-board ram, user code data area, ; start main program at $7000 main: bsr init ; branch to init subroutine to initialize atd bsr convert ; branch to convert subroutine for conversion done: bra done ; branch to self, convenient place for breakpoint ; ---------------------------------------------- ; subroutine init: initialize atd ; ; ---------------------------------------------- init: ldaa #$80 ; allow atd to function normally, staa atdctl2 ; atd flags clear normally & disable interrupts bsr delay ; delay (100 us) for wait delay time. ldaa #$00 ; select continue conversion in bgnd mode staa atdctl3 ; ignore freeze in atdctl3 ldaa #$01 ; select final sample time = 2 a/d clocks staa atdctl4 ; prescaler = div by 4 (prs4:0 = 1) rts ; return from subroutine
MC68HC812A4 ? rev. 5.0 advance information 304 analog-to-digital converter (atd) motorola analog-to-digital converter (atd) ; ---------------------------------------------- ; subroutine convert: ; ; ---------------------------------------------- ; set-up atd, make single conversion and store the result to a memory location. ; configure and start a/d conversion ; analog input signal: on port ad6 ; convert: using single channel, non-continuous ; the result will be located in adr2h convert: ldaa #$06 ; initializes atd scan=0,mult=0, pad6, ; ; write clears flag staa atdctl5 ; 4 conversions on a single conversion ; ; sequence, wtconv: brclr atdstath,#$80,wtconv ; wait for sequence complete flag ldd adr2h ; loads conversion result(adr2h) ; ; into accumulator bra convert ; continuously updates results rts ; return from subroutine ;* ------------------------------- ;* subroutine delay 100 us * ;* ------------------------------- ; delay required for atd converter to stabilize (100 usec) ldaa #$c8 ; load accumulator with "100 usec delay value" delay: deca ; decrement acc bne delay ; branch if not equal to zero rts ; return from subroutine end ; end of program
advance information MC68HC812A4 ? rev. 5.0 motorola development support 305 advance information ? MC68HC812A4 section 17. development support 17.1 contents 17.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .305 17.3 instruction queue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .306 17.4 background debug mode (bdm) . . . . . . . . . . . . . . . . . . . . . .307 17.4.1 bdm serial interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . .308 17.4.2 enabling bdm firmware commands . . . . . . . . . . . . . . . . .311 17.4.3 bdm commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .311 17.5 bdm registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .314 17.5.1 bdm instruction register . . . . . . . . . . . . . . . . . . . . . . . . . .314 17.5.1.1 hardware command . . . . . . . . . . . . . . . . . . . . . . . . . . .314 17.5.1.2 firmware command. . . . . . . . . . . . . . . . . . . . . . . . . . . .315 17.5.2 bdm status register . . . . . . . . . . . . . . . . . . . . . . . . . . . . .317 17.5.3 bdm shift register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .318 17.5.4 bdm address register . . . . . . . . . . . . . . . . . . . . . . . . . . . .318 17.5.5 bdm ccr holding register . . . . . . . . . . . . . . . . . . . . . . . . 319 17.6 instruction tagging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .319 17.2 introduction this section describes:  instruction queue  queue tracking signals  background debug mode (bdm)  instruction tagging
MC68HC812A4 ? rev. 5.0 advance information 306 development support motorola development support 17.3 instruction queue the cpu12 instruction queue provides at least three bytes of program information to the cpu when instruction execution begins. the cpu12 always completely finishes executing an instruction before beginning to execute the next instruction. status signals ipipe[1:0] provide information about data movement in the queue and indicate when the cpu begins to execute instructions. this makes it possible to monitor cpu activity on a cycle-by-cycle basis for debugging. information available on the ipipe[1:0] pins is time multiplexed. external circuitry can latch data movement information on rising edges of the e-clock signal; execution start information can be latched on falling edges. table 17-1 shows the meaning of data on the pins. table 17-1. ipipe decoding data movement ? ipipe[1:0] captured at rising edge of e clock (1) 1. refers to data that was on the bus at the previous e falling edge. ipipe[1:0] mnemonic meaning 0:0 ? no movement 0:1 lat latch data from bus 1:0 ald advance queue and load from bus 1:1 all advance queue and load from latch execution start ? ipipe[1:0] captured at falling edge of e clock (2) 2. refers to bus cycle starting at this e falling edge. ipipe[1:0] mnemonic meaning 0:0 ? no start 0:1 int start interrupt sequence 1:0 sev start even instruction 1:1 sod start odd instruction
development support background debug mode (bdm) advance information MC68HC812A4 ? rev. 5.0 motorola development support 307 program information is fetched a few cycles before it is used by the cpu. to monitor cycle-by-cycle cpu activity, it is necessary to externally reconstruct what is happening in the instruction queue. internally, the mcu only needs to buffer the data from program fetches. for system debug, it is necessary to keep the data and its associated address in the reconstructed instruction queue. the raw signals required for reconstruction of the queue are addr, data, r/w , eclk, and status signals ipipe[1:0]. the instruction queue consists of two 16-bit queue stages and a holding latch on the input of the first stage. to advance the queue means to move the word in the first stage to the second stage and move the word from either the holding latch or the data bus input buffer into the first stage. to start even (or odd) instruction means to execute the opcode in the high-order (or low-order) byte of the second stage of the instruction queue. 17.4 background debug mode (bdm) background debug mode (bdm) is used for:  system development  in-circuit testing  field testing  programming bdm is implemented in on-chip hardware and provides a full set of debug options. because bdm control logic does not reside in the cpu, bdm hardware commands can be executed while the cpu is operating normally. the control logic generally uses cpu dead cycles to execute these commands, but can steal cycles from the cpu when necessary. other bdm commands are firmware based and require the cpu to be in active background mode for execution. while bdm is active, the cpu executes a firmware program located in a small on-chip rom that is available in the standard 64-kbyte memory map only while bdm is active.
MC68HC812A4 ? rev. 5.0 advance information 308 development support motorola development support the bdm control logic communicates with an external host development system serially, via the bkgd pin. this single-wire approach minimizes the number of pins needed for development support. 17.4.1 bdm serial interface the bdm serial interface requires the external controller to generate a falling edge on the bkgd pin to indicate the start of each bit time. the external controller provides this falling edge whether data is transmitted or received. bkgd is a pseudo-open-drain pin that can be driven either by an external controller or by the mcu. data is transferred msb first at 16 e-clock cycles per bit (nominal speed). the interface times out if 512 e-clock cycles occur between falling edges from the host. the hardware clears the command register when this timeout occurs. the bkgd pin can receive a high or low level or transmit a high or low level. the following diagrams show timing for each of these cases. interface timing is synchronous to mcu clocks but asynchronous to the external host. the internal clock signal is shown for reference in counting cycles. figure 17-1 shows an external host transmitting a logic 1 or 0 to the bkgd pin of a target m68hc12 mcu. the host is asynchronous to the target so there is a 0-to-1 cycle delay from the host-generated falling edge to where the target perceives the beginning of the bit time. ten target e cycles later, the target senses the bit level on the bkgd pin. typically, the host actively drives the pseudo-open-drain bkgd pin during host-to-target transmissions to speed up rising edges. since the target does not drive the bkgd pin during this period, there is no need to treat the line as an open-drain signal during host-to-target transmissions.
development support background debug mode (bdm) advance information MC68HC812A4 ? rev. 5.0 motorola development support 309 figure 17-1. bdm host-to-target serial bit timing figure 17-2 shows the host receiving a logic 1 from the target MC68HC812A4 mcu. since the host is asynchronous to the target mcu, there is a 0-to-1 cycle delay from the host-generated falling edge on bkgd to the perceived start of the bit time in the target mcu. the host holds the bkgd pin low long enough for the target to recognize it (at least two target e cycles). the host must release the low drive before the target mcu drives a brief active-high speed-up pulse seven cycles after the perceived start of the bit time. the host should sample the bit level about 10 cycles after it started the bit time. figure 17-3 shows the host receiving a logic 0 from the target MC68HC812A4 mcu. since the host is asynchronous to the target mcu, there is a 0-to-1 cycle delay from the host-generated falling edge on bkgd to the start of the bit time as perceived by the target mcu. the host initiates the bit time but the target MC68HC812A4 finishes it. since the target wants the host to receive a logic 0, it drives the bkgd pin low for 13 e-clock cycles, then briefly drives it high to speed up the rising edge. the host samples the bit level about 10 cycles after starting the bit time. earliest start target senses bit level 10 cycles synchronization uncertainty e clock (target mcu) host transmit 1 host transmit 0 perceived start of bit time of next bit
MC68HC812A4 ? rev. 5.0 advance information 310 development support motorola development support figure 17-2. bdm target-to-host serial bit timing (logic 1) figure 17-3. bdm target-to-host serial bit timing (logic 0) host samples bkgd pin 10 cycles e-clock target mcu host drive to bkgd pin target mcu speed-up pulse perceived start of bit time high-impedance high-impedance high-impedance bkgd pin r-c rise 10 cycles earliest start of next bit 10 cycles e-clock target mcu host drive to bkgd pin target mcu drive and perceived start of bit time high-impedance bkgd pin 10 cycles speed-up pulse speed-up pulse earliest start of next bit host samples bkgd pin
development support background debug mode (bdm) advance information MC68HC812A4 ? rev. 5.0 motorola development support 311 17.4.2 enabling bdm firmware commands bdm is available in all operating modes, but must be made active before firmware commands can be executed. bdm is enabled by setting the enbdm bit in the bdm status register via the single wire interface (using a hardware command; write_bd_byte at $ff01). bdm must then be activated to map bdm registers and rom to addresses $ff00 to $ffff and to put the mcu in active background mode. after the firmware is enabled, bdm can be activated by the hardware background command, by the bdm tagging mechanism, or by the cpu bgnd instruction. an attempt to activate bdm before firmware has been enabled causes the mcu to resume normal instruction execution after a brief delay. bdm becomes active at the next instruction boundary following execution of the bdm background command, but tags activate bdm before a tagged instruction is executed. in special single-chip mode, background operation is enabled and active immediately out of reset. this active case replaces the m68hc11 boot function and allows programming a system with blank memory. while bdm is active, a set of bdm control registers are mapped to addresses $ff00 to $ff06. the bdm control logic uses these registers which can be read anytime by bdm logic, not user programs. refer to 17.5 bdm registers for detailed descriptions. some on-chip peripherals have a bdm control bit which allows suspending the peripheral function during bdm. for example, if the timer control is enabled, the timer counter is stopped while in bdm. once normal program flow is continued, the timer counter is re-enabled to simulate real-time operations. 17.4.3 bdm commands all bdm command opcodes are eight bits long and can be followed by an address and/or data, as indicated by the instruction. these commands do not require the cpu to be in active bdm mode for execution.
MC68HC812A4 ? rev. 5.0 advance information 312 development support motorola development support the host controller must wait 150 cycles for a non-intrusive bdm command to execute before another command can be sent. this delay includes 128 cycles for the maximum delay for a dead cycle. for data read commands, the host must insert this delay between sending the address and attempting to read the data. bdm logic retains control of the internal buses until a read or write is completed. if an operation can be completed in a single cycle, it does not intrude on normal cpu operation. however, if an operation requires multiple cycles, cpu clocks are frozen until the operation is complete. the cpu must be in background mode to execute commands that are implemented in the bdm rom. the bdm rom is located at $ff20 to $ffff while bdm is active. there are also seven bytes of bdm registers which are located at $ff00 to $ff06 while bdm is active. the cpu executes code from this rom to perform the requested operation. these commands are shown in table 17-2 and table 17-3 . table 17-2. bdm commands implemented in hardware command opcode (hex) data description background 90 none enter background mode, if firmware is enabled. read_bd_byte e4 16-bit address 16-bit data out read from memory with bdm in map (may steal cycles if external access); data for odd address on low byte, data for even address on high byte status (1) e4 ff01, 0000 0000 (out) read_bd_byte $ff01. running user code; bgnd instruction is not allowed ff01, 1000 0000 (out) read_bd_byte $ff01. bgnd instruction is allowed. ff01, 1100 0000 (out) read_bd_byte $ff01. background mode active, waiting for single wire serial command read_bd_word ec 16-bit address 16-bit data out read from memory with bdm in map (may steal cycles if external access); must be aligned access read_byte e0 16-bit address 16-bit data out read from memory with bdm out of map (may steal cycles if external access); data for odd address on low byte, data for even address on high byte read_word e8 16-bit address 16-bit data out read from memory with bdm out of map (may steal cycles if external access); must be aligned access write_bd_byte c4 16-bit address 16-bit data in write to memory with bdm in map (may steal cycles if external access); data for odd address on low byte, data for even address on high byte
development support background debug mode (bdm) advance information MC68HC812A4 ? rev. 5.0 motorola development support 313 enable_ firmware (2) c4 ff01, 1xxx xxxx (in) write byte $ff01, set the enbdm bit. this allows execution of commands which are implemented in firmware. typically, read status, or in the msb, write the result back to status. write_bd_word cc 16-bit address 16-bit data in write to memory with bdm in map (may steal cycles if external access); must be aligned access write_byte c0 16-bit address 16-bit data in write to memory with bdm out of map (may steal cycles if external access); data for odd address on low byte, data for even address on high byte write_word c8 16-bit address 16-bit data in write to memory with bdm out of map (may steal cycles if external access); must be aligned access 1. status command is a specific case of the read_bd_byte command. 2. enable_firmware is a specific case of the write_bd_byte command. table 17-2. bdm commands implemented in hardware (continued) command opcode (hex) data description table 17-3. bdm firmware commands command opcode (hex) data description read_next 62 16-bit data out x = x + 2; read next word pointed to by x read_pc 63 16-bit data out read program counter read_d 64 16-bit data out read d accumulator read_x 65 16-bit data out read x index register read_y 66 16-bit data out read y index register read_sp 67 16-bit data out read stack pointer write_next 42 16-bit data in x = x + 2; write next word pointed to by x write_pc 43 16-bit data in write program counter write_d 44 16-bit data in write d accumulator write_x 45 16-bit data in write x index register write_y 46 16-bit data in write y index register write_sp 47 16-bit data in write stack pointer go 08 none go to user program trace1 10 none execute one user instruction, then return to bdm taggo 18 none enable tagging and go to user program
MC68HC812A4 ? rev. 5.0 advance information 314 development support motorola development support 17.5 bdm registers seven bdm registers are mapped into the standard 64-kbyte address space when bdm is active. the registers can be accessed with the hardware read_bd and write_bd commands, but must not be written during bdm operation. most users are only interested in the status register at $ff01; other registers are for use only by bdm firmware and logic. the instruction register is discussed for two conditions:  when a hardware command is executed  when a firmware command is executed 17.5.1 bdm instruction register this section describes the bdm instruction register under hardware command and firmware command. 17.5.1.1 hardware command the bits in the bdm instruction register have the following meanings when a hardware command is executed. h/f ? hardware/firmware flag 1 = hardware instruction 0 = firmware instruction data ? data flag 1 = data included in command 0 = no data address: $ff00 bit 7654321bit 0 read: h/f data r/w bkgnd w/b bd/u 0 0 write: reset:00000000 figure 17-4. bdm instruction register (instruction)
development support bdm registers advance information MC68HC812A4 ? rev. 5.0 motorola development support 315 r/w ? read/write flag 0 = write 1 = read bkgnd ? hardware request bit to enter active background mode 1 = hardware background command (instruction = $90) 0 = not a hardware background command w/b ? word/byte transfer flag 1 = word transfer 0 = byte transfer bd/u ? bdm map/user map flag indicates whether bdm registers and rom are mapped to addresses $ff00 to $ffff in the standard 64-kbyte address space. used only by hardware read/write commands. 1 = bdm resources in map 0 = bdm resources not in map 17.5.1.2 firmware command the bits in the bdm instruction register have the following meanings when a firmware command is executed. h/f ? hardware/firmware flag 1 = hardware control logic 0 = firmware control logic data ? data flag 1 = data included in command 0 = no data address: $ff00 bit 7654321bit 0 read: h/f data r/w ttago regn write: reset:00000000 figure 17-5. bdm instruction register (instruction)
MC68HC812A4 ? rev. 5.0 advance information 316 development support motorola development support r/w ? read/write flag 1 = read 0 = write ttago ? trace, tag, and go field regn ? register/next field indicates which register is being affected by a command. in the case of a read_next or write_next command, index register x is pre-incremented by 2 and the word pointed to by x is then read or written. table 17-4. ttago decoding ttago value instruction 00 ? 01 go 10 trace1 11 taggo table 17-5. regn decoding regn value instruction 000 ? 001 ? 010 read/write next 011 pc 100 d 101 x 110 y 111 sp
development support bdm registers advance information MC68HC812A4 ? rev. 5.0 motorola development support 317 17.5.2 bdm status register this register can be read or written by bdm commands or firmware. enbdm ? enable bdm bit (permit active background debug mode) 1 = bdm can be made active to allow firmware commands. 0 = bdm cannot be made active (hardware commands still allowed). bdmact ? background mode active status bit 1 = bdm active and waiting for serial commands 0 = bdm not active entag ? instruction tagging enable bit set by the taggo instruction and cleared when bdm is entered. 1 = tagging active (bdm cannot process serial commands while tagging is active.) 0 = tagging not enabled or bdm active sdv ? shifter data valid bit shows that valid data is in the serial interface shift register. used by firmware-based instructions. 1 = valid data 0 = no valid data trace ? asserted by the trace1 instruction address: $ff01 bit 76 54321bit 0 read: enbdm edmact entag sdv trace 0 0 0 write: reset:0 0 000000 single-chip peripheral: 1 0 000000 figure 17-6. bdm status register (status)
MC68HC812A4 ? rev. 5.0 advance information 318 development support motorola development support 17.5.3 bdm shift register this 16-bit register contains data being received or transmitted via the serial interface. 17.5.4 bdm address register this 16-bit register is temporary storage for bdm hardware and firmware commands. address: $ff02 bit 7654321bit 0 read: s15 s14 s13 s12 s11 s10 s9 s8 write: reset:00000000 address: $ff03 bit 7654321bit 0 read: s7 s6 s5 s4 s3 s2 s1 s0 write: reset:00000000 figure 17-7. bdm shift register (shifter) address: $ff04 bit 7654321bit 0 read: a15 a14 a13 a12 a11 a10 a9 a8 write: reset:00000000 address: $ff05 bit 7654321bit 0 read: a7 a6 a5 a4 a3 a2 a1 a0 write: reset:00000000 figure 17-8. bdm address register (address)
development support instruction tagging advance information MC68HC812A4 ? rev. 5.0 motorola development support 319 17.5.5 bdm ccr holding register this register preserves the content of the cpu12 ccr while bdm is active. 17.6 instruction tagging the instruction queue and cycle-by-cycle cpu activity can be reconstructed in real time or from trace history that was captured by a logic analyzer. however, the reconstructed queue cannot be used to stop the cpu at a specific instruction, because execution has already begun by the time an operation is visible outside the mcu. a separate instruction tagging mechanism is provided for this purpose. executing the bdm taggo command configures two mcu pins for tagging. tagging information is latched on the falling edge of eclk along with program information as it is fetched. tagging is allowed in all modes. tagging is disabled when bdm becomes active and bdm serial commands cannot be processed while tagging is active. taghi is a shared function of the bkgd pin. taglo is a shared function of the pe3/lstrb pin, a multiplexed i/o pin. for 1/4 cycle before and after the rising edge of the e-clock, this pin is the lstrb driven output. taglo and taghi inputs are captured at the falling edge of the e-clock. a logic 0 on taghi and/or taglo marks (tags) the instruction on the high and/or low byte of the program word that was on the data bus at the same falling edge of the e-clock. address: $ff06 bit 7654321bit 0 read: ccr7 ccr6 ccr5 ccr4 ccr3 ccr2 ccr1 ccr0 write: reset:00000000 figure 17-9. bdm ccr holding register (ccrsav)
MC68HC812A4 ? rev. 5.0 advance information 320 development support motorola development support the tag follows the information in the queue as the queue is advanced. when a tagged instruction reaches the head of the queue, the cpu enters active background debugging mode rather than executing the instruction. this is the mechanism by which a development system initiates hardware breakpoints.
advance information MC68HC812A4 ? rev. 5.0 motorola electrical characteristics 321 advance information ? MC68HC812A4 section 18. electrical characteristics 18.1 contents 18.2 maximum ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .322 18.3 functional operating range. . . . . . . . . . . . . . . . . . . . . . . . . .323 18.4 thermal characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . .323 18.5 dc electrical characteristics . . . . . . . . . . . . . . . . . . . . . . . . . 324 18.6 supply current . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .325 18.7 atd maximum ratings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 18.8 atd dc electrical characteristcs. . . . . . . . . . . . . . . . . . . . . . 326 18.9 analog converter operating characteristics . . . . . . . . . . . . .327 18.10 atd ac operating characteristics . . . . . . . . . . . . . . . . . . . . .328 18.11 eeprom characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . .328 18.12 control timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .329 18.13 peripheral port timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .333 18.14 non-multiplexed expansion bus timing . . . . . . . . . . . . . . . . .334 18.15 spi timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .336
MC68HC812A4 ? rev. 5.0 advance information 322 electrical characteristics motorola electrical characteristics 18.2 maximum ratings maximum ratings are the extreme limits to which the mcu can be exposed without permanently damaging it. note: this device is not guaranteed to operate properly at the maximum ratings. refer to 18.5 dc electrical characteristics for guaranteed operating conditions. note: this device contains circuitry to protect the inputs against damage due to high static voltages or electric fields; however, it is advised that normal precautions be taken to avoid application of any voltage higher than maximum-rated voltages to this high-impedance circuit. for proper operation, it is recommended that v in and v out be constrained to the range v ss (v in or v out ) v dd . reliability of operation is enhanced if unused inputs are connected to an appropriate logic voltage level (for example, either v ss or v dd ). rating symbol value unit supply voltage v dd v dda v ddx ? 0.3 to +6.5 v input voltage v in ? 0.3 to +6.5 v maximum current per pin excluding v dd and v ss i in 25 ma storage temperature t stg ? 55 to +150 c v dd differential voltage v dd ? v ddx 6.5 v
electrical characteristics functional operating range advance information MC68HC812A4 ? rev. 5.0 motorola electrical characteristics 323 18.3 functional operating range 18.4 thermal characteristics rating symbol value unit operating temperature range MC68HC812A4pv8 MC68HC812A4cpv8 MC68HC812A4 vpv8 MC68HC812A4mpv8 t a t l to t h 0 to + 70 ? 40 to + 85 ? 40 to + 105 ? 40 to + 125 c operating voltage range v dd 5.0 10% v characteristic symbol value unit average junction temperature t j t a + (p d ja ) c ambient temperature t a user-determined c package thermal resistance (junction-to-ambient) 112-pin thin quad flat pack (tqfp) ja 39 c/w total power dissipation (1) 1. this is an approximate value, neglecting p i/o . p d p int + p i/o or w device internal power dissipation p int i dd v dd w i/o pin power dissipation (2) 2. for most applications, p i/o ? p int and can be neglected. p i/o user-determined w a constant (3) 3. k is a constant pertaining to the device. solve for k with a known t a and a measured p d (at equilibrium). use this value of k to solve for p d and t j iteratively for any value of t a . k p d (t a + 273 c) + ja p d 2 w/ c k t j 273 c + ------------------------- -
MC68HC812A4 ? rev. 5.0 advance information 324 electrical characteristics motorola electrical characteristics 18.5 dc electrical characteristics characteristic (1) symbol min max unit input high voltage, all inputs v ih 0.7 v dd v dd + 0.3 v input low voltage, all inputs v il v ss ? 0.3 0.2 v dd v output high voltage, all i/o and output pins normal drive strength i oh = ? 10.0 a i oh = ? 0.8 ma reduced drive strength i oh = ? 4.0 a i oh = ? 0.3 ma v oh v dd ? 0.2 v dd ? 0.8 v dd ? 0.2 v dd ? 0.8 ? ? ? ? v output low voltage, all i/o and output pins, normal drive strength i ol = 10.0 a i ol = 1.6 ma extal, pad[7:0], v rh , v rl , v fp , xirq , reduced drive strength i ol = 3.6 a i ol = 0.6 ma v ol ? ? ? ? v ss + 0.2 v ss + 0.4 v ss + 0.2 v ss + 0.4 v input leakage current (2) all input pins v in = v dd or v ss ? v rl , v rh , pad6 ? pad0 v in = v dd or v ss ? irq v in = v dd or v ss ? pad7 i in ? ? ? 1 10 10 a three-state leakage, i/o ports, bkgd, and reset i oz ? 2.5 a input capacitance all input pins and atd pins (non-sampling) atd pins (sampling) all i/o pins c in ? ? ? 10 15 20 pf output load capacitance all outputs except ps7 ? ps4 ps7 ? ps4 c l ? ? 90 200 pf active pullup, pulldown current irq , xirq , dbe , eclk, lstrb , r/w , and bkgd ports a, b, c, d, f, g, h, j, p, s, and t i apu 50 500 a ram standby voltage, power down v sb 1.5 ? v ram standby current i sb ? 10 a 1. v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h , unless otherwise noted 2. specification is for parts in the ? 40 to + 85 c range. higher temperature ranges will result in increased current leakage.
electrical characteristics supply current advance information MC68HC812A4 ? rev. 5.0 motorola electrical characteristics 325 18.6 supply current 18.7 atd maximum ratings ? characteristic (1) symbol 8 mhz typical 2 mhz 4 mhz 8 mhz unit maximum total supply current run single-chip mode expanded mode wait, all peripheral functions shut down single-chip mode expanded mode stop, single-chip mode, no clocks ? 40 c to +85 c +85 c to +105 c +105 c to +125 c i dd wi dd si dd 30 47 7 8 < 1 < 10 < 25 15 25 1.5 4 10 25 50 25 40 4 5 10 25 50 40 65 8 10 10 25 50 ma ma ma ma a a a maximum power dissipation (2) single-chip mode expanded mode p d 54 76 62 90 54 76 62 90 mw mw 1. v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h , unless otherwise noted 2. includes i dd and i dda characteristic symbol value units atd reference voltage v rh v dda v rl v ssa v rh v rl ? 0.3 to + 6.5 ? 0.3 to + 6.5 v v ss differential voltage | v ss ? v ssa | 0.1 v v dd differential voltage | v dd ? v dda | v dd ? v ddx 6.5 6.5 v v ref differential voltage | v rh ? v rl | 6.5 v reference to supply differential voltage | v rh ? v dda | | v rl ? v ssa | 6.5 6.5 v
MC68HC812A4 ? rev. 5.0 advance information 326 electrical characteristics motorola electrical characteristics 18.8 atd dc electrical characteristcs characteristic (1) symbol min max unit analog supply voltage v dda 4.5 5.5 v analog supply current, normal operation i dda ? 1.0 ma reference voltage, low v rl v ssa v dda / 2 v reference voltage, high v rh v dda / 2v dda v v ref differential reference voltage (2) v rh ? v rl 4.5 5.5 v input voltage (3) v indc v ssa v dda v input current, off channel (4) i off ? 100 na reference supply current i ref ? 250 a input capacitance not sampling sampling c inn c ins ? ? 10 15 pf 1. v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h , atd clock = 2 mhz, unless otherwise noted 2. accuracy is guaranteed at v rh ? v rl = 5.0 vdc 10% . 3. to obtain full-scale, full-range results, v ssa v rl v indc v rh v dda . 4. maximum leakage occurs at maximum operating temperature. current decreases by approximately one-half for each 10 c decrease from maximum temperature.
electrical characteristics analog converter operating characteristics advance information MC68HC812A4 ? rev. 5.0 motorola electrical characteristics 327 18.9 analog converter operating characteristics characteristic (1) symbol min typical max unit 8-bit resolution (2) 2 counts ? 24 ? mv differential non-linearity (3) dnl ? 0.5 ? + 0.5 count integral non-linearity (3) inl ? 1 ? + 1 count absolute error (3),(4) 2, 4, 8, and 16 atd sample clocks ae ? 2 ? + 2 count maximum source impedance r s ? 20 see note (5) k ? 1. v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h , atd clock = 2 mhz, unless otherwise noted 2. v rh ? v rl 5.12 v; v dda ? v ssa = 5.12 v 3. at v ref = 5.12 v, one 8-bit count = 20 mv. 4. 8-bit absolute error of 1 count (20 mv) includes 1/2 count (10 mv) inherent quantization error and 1/2 count (10 mv) circuit (differential, integral, and offset) error. 5. maximum source impedance is application-dependent. error resulting from pin leakage depends on junction leakage into the pin and on leakage due to charge-sharing with internal capacitance. error from junction leakage is a function of external source impedance and input leakage current. expected error in result value due to junction leakage is expressed in voltage (v errj ): v errj = r s i off where i off is a function of operating temperature. charge-sharing effects with internal capacitors are a function of atd clock speed, the number of channels being scanned, and source impedance. for 8-bit conversions, charge pump leakage is computed as follows: v errj = .25 pf v dda r s atdclk/(8 number of channels)
MC68HC812A4 ? rev. 5.0 advance information 328 electrical characteristics motorola electrical characteristics 18.10 atd ac operating characteristics 18.11 eeprom characteristics characteristic (1) symbol min max unit atd operating clock frequency f atdclk 0.5 2.0 mhz conversion time per channel 0.5 mhz f atdclk 2 mhz 18 atd clocks 32 atd clocks t conv 8.0 15.0 32.0 60.0 s stop recovery time v dda = 5.0 v t sr ? 50 s 1. v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h , atd clock = 2 mhz, unless otherwise noted characteristic (1) symbol min typical max unit minimum programming clock frequency (2) f prog 1.0 ?? mhz programming time t prog 10.0 ? 10.5 ms clock recovery time following stop, to continue programming t crstop ?? t prog + 1 ms erase time t erase 10.0 ? 10.5 ms write/erase endurance ? 10,000 30,000 (3) ? cycles data retention ? 10 ?? ye a r s 1. v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h , unless otherwise noted 2. rc oscillator must be enabled if programming is desired and f sys < f prog . 3. if average t h is below 85 c
electrical characteristics control timing advance information MC68HC812A4 ? rev. 5.0 motorola electrical characteristics 329 18.12 control timing figure 18-1. timer inputs characteristic symbol 8.0 mhz unit min max frequency of operation f o dc 5.0 mhz e-clock period t cyc 125 ? ns crystal frequency f xtal ? 16.0 mhz external oscillator frequency 2 f o dc 16.0 mhz processor control setup time t pcsu = t cyc / 2 + 30 t pcsu 82 ? ns reset input pulse width to guarantee external reset vector minimum input time (can be pre-empted by internal reset) pw rstl 32 2 ? ? t cyc mode programming setup time t mps 4 ? t cyc mode programming hold time t mph 10 ? ns interrupt pulse width, irq , edge-sensitive mode, kwu pw irq = 2 t cyc + 20 pw irq 270 ? ns wait recovery startup time t wrs ? 4t cyc timer pulse width, input capture pulse accumulator input pw tim = 2 t cyc + 20 pw tim 270 ? ns pt7 (2) pt7 (1) pt[7:0] (2) pt[7:0] (1) notes: 1. rising edge-sensitive input 2. falling edge-sensitive input pw tim pw pa
MC68HC812A4 ? rev. 5.0 advance information 330 electrical characteristics motorola electrical characteristics figure 18-2. por and external reset timing diagram t pcsu internal moda, modb eclk extal v dd reset 4098 t cyc free fffe fffe 3rd 1st 2nd free fffe fffe fffe t mph pw rstl t mps address pipe pipe pipe 1st exec 3rd pipe 2nd pipe 1st pipe 1st exec note: reset timing is subject to change.
advance information MC68HC812A4 ? rev. 5.0 motorola electrical characteristics 331 electrical characteristics control timing figure 18-3. stop recovery timing diagram pw irq t stopdelay (3) irq 1 irq or xirq eclk 1st address 4 sp-9 free free vector free free resume program with instruction which follows the stop instruction. internal address 5 clocks notes: 1. edge-sensitive irq pin (irqe bit = 1) 2. level-sensitive irq pin (irqe bit = 0) 3. t stopdelay = 4098 t cyc if dly bit = 1 or 2 t cyc if dly = 0. 4. xirq with x bit in ccr = 1. 5. irq or (xirq with x bit in ccr = 0) opt 1st 2nd 3rd 1st exec pipe pipe exec sp-8 sp-6 fetch pipe sp-6 sp-8 sp-9
MC68HC812A4 ? rev. 5.0 advance information 332 electrical characteristics motorola electrical characteristics figure 18-4. wait recovery timing diagram figure 18-5. interrupt timing diagram t pcsu pc, iy, ix, b:a, , ccr stack registers eclk r/w address irq , xirq , or internal interrupts sp ? 2 sp ? 4 sp ? 6 . . . sp ? 9 sp ? 9 sp ? 9. . . sp ? 9 sp ? 9 vector free 1st 2nd 3rd pipe t wrs note: reset also causes recovery from wait. address pipe pipe 1st exec eclk pw irq 1st 3rd address irq (1) sp ? 9 t pcsu irq (2) , xirq , or internal interrupt vector sp ? 2 1st sp ? 4sp ? 6 2nd sp ? 8 data vect pc iy ix b:a ccr prog r/w notes: 1. edge sensitive irq pin (irqe bit = 1) 2. level sensitive irq pin (irqe bit = 0) fetch addr exec pipe pipe pipe prog fetch prog fetch
electrical characteristics peripheral port timing advance information MC68HC812A4 ? rev. 5.0 motorola electrical characteristics 333 18.13 peripheral port timing figure 18-6. port read timing diagram figure 18-7. port write timing diagram characteristic symbol 5.0 mhz unit min max frequency of operation (e-clock frequency) f o dc 8.0 mhz e-clock period t cyc 125 ? ns peripheral data setup time, mcu read of ports t pdsu = t cyc / 2 + 30 t pdsu 102 ? ns peripheral data hold time, mcu read of ports t pdh 0 ? ns delay time, peripheral data write, mcu write to ports t pwd ? 40 ns eclk mcu read of port ports t pdsu t pdh eclk mcu write to port previous port data new data valid port a t pwd
MC68HC812A4 ? rev. 5.0 advance information 334 electrical characteristics motorola electrical characteristics 18.14 non-multiplexed expansion bus timing num characteristic (1), (2) delay symbol 8 mhz unit min max frequency of operation (e-clock frequency) ? f o dc 8.0 mhz 1 cycle time t cyc = 1 / f o t cyc 125 ? ns 2 pulse width, e low pw el = t cyc / 2 + delay ? 2 pw el 60 ? ns 3 pulse width, e high (3) pw eh = t cyc / 2 + delay ? 2 pw eh 60 ? ns 5 address delay time t ad = t cyc / 4 + delay 29 t ad ? 60 ns 6 address hold time ? t ah 20 ? ns 7 address valid time to e rise t av = pw el ? t ad ? t av 0 ? ns 11 read data setup time ? t dsr 30 ? ns 12 read data hold time ? t dhr 0 ? ns 13 write data delay time t ddw = t cyc / 4 + delay 25 t ddw ? 46 ns 14 write data hold time ? t dhw 20 ? ns 15 write data setup time (3) t dsw = pw eh ? t ddw ? t dsw 30 ? ns 16 read/write delay timw t rwd = t cyc / 4 + delay 18 t rwd ? 49 ns 17 read/write valid time to e rise t rwv = pw el ? t rwd ? t rwv 20 ? ns 18 read/write hold time ? t rwh 20 ? ns 19 low strobe delay time t lsd = t cyc / 4 + delay 18 t lsd ? 49 ns 20 low strobe valid time to e rise t lsv = pw el ? t lsd ? t lsv 11 ? ns 21 low strobe hold time ? t lsh 20 ? ns 22 address access time (3) t acca = t cyc ? t ad ? t dsr ? t acca ? 35 ns 23 access time from e rise (3) t acce = pw eh ? t dsr ? t acce ? 30 ns 26 chip-select delay time t csd = t cyc / 4 + delay 29 t csd ? 60 ns 27 chip-select access time (3) t accs = t cyc ? t csd ? t dsr ? t accs ? 65 ns 28 chip-select hold time ? t csh 010ns 29 chip-select negated time t csn = t cyc / 4 + delay 5t csn 36 ? ns 1. v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h , unless otherwise noted 2. all timings are calculated for normal port drives. 3. this characteristic is affected by clock stretch. add n t cyc where n = 0, 1, 2, or 3, depending on the number of clock stretches.
electrical characteristics non-multiplexed expansion bus timing advance information MC68HC812A4 ? rev. 5.0 motorola electrical characteristics 335 figure 18-8. non-multiplexed expansion bus timing diagram eclk r/w 1 6 data[15:0] data[15:0] 2 3 18 22 11 12 13 14 addr[15:0] note: measurement points shown are 20% and 70% of v dd . 5 15 cs 16 27 28 17 read write 23 lstrb 21 19 20 (w/o tag enabled) 26 29 7
MC68HC812A4 ? rev. 5.0 advance information 336 electrical characteristics motorola electrical characteristics 18.15 spi timing num function (1), (2) symbol min max unit operating frequency master slave f op dc dc 1 / 2 1 / 2 e-clock frequency 1 sck period master slave t sck 2 2 256 ? t cyc 2 enable lead time master slave t lead 1 / 2 1 ? ? t sck t cyc 3 enable lag time master slave t lag 1 / 2 1 ? ? t sck t cyc 4 clock (sck) high or low time master slave t wsck t cyc ? 60 t cyc ? 30 128 t cyc ? ns 5 sequential transfer delay master slave t td 1 / 2 1 ? ? t sck t cyc 6 data setup time (inputs) master slave t su 30 30 ? ? ns 7 data hold time (inputs) master slave t hi 0 30 ? ? ns 8 slave access time t a ? 1 t cyc 9 slave miso disable time t dis ? 1 t cyc 10 data valid (after sck edge) master slave t v ? ? 50 50 ns 11 data hold time (outputs) master slave t ho 0 0 ? ? ns 12 rise time input output t ri t ro ? ? t cyc ? 30 30 ns ns 13 fall time input output t fi t fo ? ? t cyc ? 30 30 ns ns 1. v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h , 200 pf load on all spi pins 2. all ac timing is shown with respect to 20% v dd and 70% v dd levels, unless otherwise noted.
electrical characteristics spi timing advance information MC68HC812A4 ? rev. 5.0 motorola electrical characteristics 337 a) spi master timing (cpha = 0) b) spi master timing (cpha = 1) figure 18-9. spi timing diagram (sheet 1 of 2) sck (output sck output miso input mosi output ss (1) output 1 10 6 7 msb in (2) bit 6 . . . 1 lsb in msb out (2) lsb out bit 6 . . . 1 11 4 4 2 10 cpol = 0 cpol = 1 5 3 12 13 1. ss output mode (dds7 = 1, ssoe = 1) 2. lsbf = 0. for lsbf = 1, bit order is lsb, bit 1, ..., bit 6, msb notes: sck output sck output miso input mosi output 1 6 7 msb in (2) bit 6 . . . 1 lsb in master msb out (2) master lsb out bit 6 . . . 1 4 4 10 12 13 11 port data cpol = 0 cpol = 1 port data ss (1) output 5 2 13 12 3 1. ss output mode (dds7 = 1, ssoe = 1) 2. lsbf = 0. for lsbf = 1, bit order is lsb, bit 1, ..., bit 6, msb notes:
MC68HC812A4 ? rev. 5.0 advance information 338 electrical characteristics motorola electrical characteristics a) spi slave timing (cpha = 0) b) spi slave timing (cpha = 1) figure 18-9. spi timing diagram (sheet 2 of 2) sck input sck input mosi input miso output ss input 1 10 6 7 msb in bit 6 . . . 1 lsb in msb out slave lsb out bit 6 . . . 1 11 4 4 2 8 cpol = 0 cpol = 1 5 3 13 note: not defined but normally msb of character just received slave 13 12 11 see 12 note 9 sck input sck input mosi input miso output 1 6 7 msb in bit 6 . . . 1 lsb in msb out slave lsb out bit 6 . . . 1 4 4 10 12 13 11 see cpol = 0 cpol = 1 ss input 5 2 13 12 3 note: not defined but normally lsb of character just received slave note 8 9
advance information MC68HC812A4 ? rev. 5.0 motorola mechanical specifications 339 advance information ? MC68HC812A4 section 19. mechanical specifications 19.1 contents 19.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .339 19.3 112-pin low-profile quad flat pack (case 987) . . . . . . . . . .340 19.2 introduction this section provides dimensions for the 112-lead low-profile quad flat pack (lqfp). the following figure shows the latest package drawing at the time of this publication. to make sure that you have the latest package specifications, contact one of the following:  local motorola sales office  world wide web at http://www.motorola.com/mcu/ follow world wide web on-line instructions to retrieve the current mechanical specifications.
MC68HC812A4 ? rev. 5.0 advance information 340 mechanical specifications motorola mechanical specifications 19.3 112-pin low-profile quad flat pack (case 987) dim a min max 20.000 bsc millimeters a1 10.000 bsc b 20.000 bsc b1 10.000 bsc c --- 1.600 c1 0.050 0.150 c2 1.350 1.450 d 0.270 0.370 e 0.450 0.750 f 0.270 0.330 g 0.650 bsc j 0.090 0.170 k 0.500 ref p 0.325 bsc r1 0.100 0.200 r2 0.100 0.200 s 22.000 bsc s1 11.000 bsc v 22.000 bsc v1 11.000 bsc y 0.250 ref z 1.000 ref aa 0.090 0.160 notes: 1. dimensions and tolerances per asme y14.5m, 1994. 2. dimensions in millimeters. 3. datums l, m and n to be determined at seating plane, datum t. 4. dimensions s and v to be determined at seating plane, datum t. 5. dimensions a and b do not include mold protrusion. allowable protrusion is 0.25 per side. dimensions a and b include mold mismatch. 6. dimension d does not include dambar protrusion. allowable dambar protrusion shall not cause the d dimension to exceed 0.46. 0 3 11 11 8 7 13 13 view y l-m 0.20 n t 4x 4x 28 tips pin 1 ident 1 112 85 84 28 57 29 56 b v v1 b1 a1 s1 a s view ab 0.10 3 c c2 2 0.050 seating plane gage plane 1 view ab c1 (z) (y) e (k) r2 r1 0.25 j1 view y j1 p g 108x 4x section j1-j1 base rotated 90 counterclockwise metal j aa f d l-m m 0.13 n t 1 2 3 c l l-m 0.20 n t l n m t t 112x x x=l, m or n r r
blank
mc68hc 8 12a 4 /d rev 5 mc 68hc912b32 technical data how to reach us: usa/europe/locations not listed: motorola literature distribution p.o. box 5405 denver, colorado 80217 1-303-675-2140 1-800-441-2447 technical information center: 1-800-521-6274 japan: motorola japan ltd. sps, technical information center 3-20-1, minami-azabu, minato-ku tokyo 106-8573 japan 81-3-3440-3569 asia/pacific: motorola semiconductors h.k. ltd. silicon harbour centre 2 dai king street tai po industrial estate tai po, n.t., hong kong 852-26668334 home page: http://www.motorola.com/semiconductors/ q4/00 rev 1


▲Up To Search▲   

 
Price & Availability of MC68HC812A4

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X